Solved

Optimize view

Posted on 2011-03-23
6
484 Views
Last Modified: 2012-05-11
Hello,

Is it possible to optimize this view ?
CREATE VIEW [livelink].[WebNodes] AS SELECT a.OwnerID,a.DataID,a.ParentID, a.UserID,a.GroupID,
a.UPermissions,a.GPermissions,a.WPermissions,a.SPermissions,a.PermID, a.Name,a.DataType,a.SubType,
a.DComment,a.DCategory,a.CreateDate,a.ModifyDate,a.ExAtt1, a.Reserved,a.ReservedBy,a.ReservedDate,a.Ordering,
a.ChildCount,a.VersionNum, a.AssignedTo,a.Status,a.Priority,a.GIF,a.Catalog, b.FileName,b.FileType,b.DataSize,
b.ResSize,b.MimeType, c.Name OwnerName,a.OriginDataID, a.Major, a.Position FROM DTree
a LEFT OUTER JOIN DVersData b ON (a.DataID=b.DocID and (a.Major = b.Version
or (a.Major IS NULL and a.VersionNum=b.Version))), KUAF c WHERE a.CreatedBy=c.ID and b.VerType is NULL
GO


Thanks
bibi
0
Comment
Question by:bibi92
  • 4
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35198461
It looks like intentionally or not you have a CROSS JOIN:
KUAF is not joined to anything.

If that is the case than use the correct syntax by losing the , and changing it to CROSS JOIN KUAF c
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35198498
See below for the same VIEW in a readable format and using the correct syntax:

Make sure the CROSS JOIN is required.
CREATE VIEW [livelink].[WebNodes]
AS
SELECT  a.OwnerID,
        a.DataID,
        a.ParentID,
        a.UserID,
        a.GroupID,
        a.UPermissions,
        a.GPermissions,
        a.WPermissions,
        a.SPermissions,
        a.PermID,
        a.Name,
        a.DataType,
        a.SubType,
        a.DComment,
        a.DCategory,
        a.CreateDate,
        a.ModifyDate,
        a.ExAtt1,
        a.Reserved,
        a.ReservedBy,
        a.ReservedDate,
        a.Ordering,
        a.ChildCount,
        a.VersionNum,
        a.AssignedTo,
        a.Status,
        a.Priority,
        a.GIF,
        a.Catalog,
        b.FileName,
        b.FileType,
        b.DataSize,
        b.ResSize,
        b.MimeType,
        c.Name OwnerName,
        a.OriginDataID,
        a.Major,
        a.Position
FROM    DTree a
        LEFT OUTER JOIN DVersData b ON a.DataID = b.DocID 
			    AND (a.Major = b.Version OR (a.Major IS NULL AND a.VersionNum = b.Version))
        CROSS JOIN KUAF c
WHERE   a.CreatedBy = c.ID
        AND b.VerType IS NULL

Open in new window

0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 35198533
Oops my mistake I see where you are relating KUAF, but do it this way:
CREATE VIEW [livelink].[WebNodes]
AS
SELECT  a.OwnerID,
        a.DataID,
        a.ParentID,
        a.UserID,
        a.GroupID,
        a.UPermissions,
        a.GPermissions,
        a.WPermissions,
        a.SPermissions,
        a.PermID,
        a.Name,
        a.DataType,
        a.SubType,
        a.DComment,
        a.DCategory,
        a.CreateDate,
        a.ModifyDate,
        a.ExAtt1,
        a.Reserved,
        a.ReservedBy,
        a.ReservedDate,
        a.Ordering,
        a.ChildCount,
        a.VersionNum,
        a.AssignedTo,
        a.Status,
        a.Priority,
        a.GIF,
        a.Catalog,
        b.FileName,
        b.FileType,
        b.DataSize,
        b.ResSize,
        b.MimeType,
        c.Name OwnerName,
        a.OriginDataID,
        a.Major,
        a.Position
FROM    DTree a
        LEFT OUTER JOIN DVersData b ON a.DataID = b.DocID 
			    AND (a.Major = b.Version OR (a.Major IS NULL AND a.VersionNum = b.Version))
        INNER JOIN KUAF c ON a.CreatedBy = c.ID
WHERE   b.VerType IS NULL

Open in new window

0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 39

Expert Comment

by:lcohan
ID: 35202443
Why not the INNER JOIN first?

CREATE VIEW [livelink].[WebNodes] AS
SELECT a.OwnerID,a.DataID,a.ParentID, a.UserID,a.GroupID, a.UPermissions,a.GPermissions,a.WPermissions,
            a.SPermissions,a.PermID, a.Name,a.DataType,a.SubType,a.DComment,a.DCategory,a.CreateDate,a.ModifyDate,
            a.ExAtt1, a.Reserved,a.ReservedBy,a.ReservedDate,a.Ordering, a.ChildCount,a.VersionNum, a.AssignedTo,
            a.[Status],a.Priority,a.GIF,a.[Catalog], b.[FileName],b.FileType,b.DataSize,b.ResSize,b.MimeType,
            c.Name OwnerName,a.OriginDataID, a.Major, a.Position
FROM DTree a
      INNER JOIN KUAF c ON a.CreatedBy=c.ID
      LEFT OUTER JOIN DVersData b ON (a.DataID=b.DocID and (a.Major = b.Version or (a.Major IS NULL and a.VersionNum=b.Version))) and b.VerType is NULL
GO
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35203525
>>Why not the INNER JOIN first?<<
Because it does not make any difference in performance?
0
 

Author Closing Comment

by:bibi92
ID: 35205839
Thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use odbc in vb to connect to ms sql 14 40
SQL Select Statement 2 22
SQL Query Syntax Join 4 34
Query to return total 6 0
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now