![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I have a view and when I add a criteria to the view, it takes a very long time, but if I just execute the SQL that I use for the view. It runs much faster. Why is this happening and is there anything I can do in the view to achieve the same performance. The following is an example of what I am talking about. SELECT * FROM vwEmployee where EmpID = 12 Execution Time: 50 seconds SELECT * FROM tblEmployee INNER JOIN Country ON EmpCountryID = CountryID LEFT OUTER JOIN Address ON EmpAddID = AddID WHERE EmpID = 12 Execution Time: 2 Seconds Thanks in advance for the help! |
#2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
--Filter(WHERE ([EmployeeDemographic].[UPN]='1601352' AND[EmployeeDemographic].[ProfileYear]='2003') AND Convert([Expr1125])=0)) --Compute Scalar(DEFINE [EmployeeDemographic].[UPN]=[EmployeeDemographic].[UPN],
|
|
--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))--Hash Match(Right Outer Join, HASH [MetricSummary].[ProfileYear],
|
[EmployeeDemographic].[ProfileYear]=[MetricSummary].[ProfileYe|
|--Clustered Index Scan(OBJECT [PDMS].[dbo].[MetricSummary].[PK_ExecutivePromotionMetricSu
|
|
|--Hash Match(Right Outer Join, HASH [ExecutivePromotion].[PLID])=([PerformanceLog].[PLId]))|--Clustered Index Scan(OBJECT [PDMS].[dbo].[ExecutivePromotion].[PK_ExecutivePromotion]))|--Compute Scalar(DEFINE [Expr1038]=Convert([PerformanceLog].[PlanCounseleeSignTim
|
|
|--Merge Join(Right Outer Join, MERGE [EmployeeDemographic].[UPN],
|
[EmployeeDemographic].[UPN]=[EmployeeDemographic].[TeamLeaderU|
|--Sort(ORDER BY [EmployeeDemographic].[UPN] ASC, [EmployeeDemographic].[ProfileYear]
|
|
| |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| |--Clustered Index Scan(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_
|
|
|--Sort(ORDER BY [EmployeeDemographic].[TeamLeaderUPN] ASC,
|
|
|--Merge Join(Right Outer Join, MERGE [EmployeeDemographic].[UPN],
|
[EmployeeDemographic].[UPN]=[EmployeeDemographic].[CounselorUP|
|--Sort(ORDER BY [EmployeeDemographic].[UPN] ASC, [EmployeeDemographic].[ProfileYear]
|
|
| |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| |--Clustered Index |
[PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_|
|--Sort(ORDER BY [EmployeeDemographic].[CounselorUPN] ASC,
|
|
|--Hash Match(Right Outer Join, |
[CareerPath].[CareerPathID])=([EmployeeDemographic].[CareerPathID]
[EmployeeDemographic].[CareerPathID]=[CareerPath].[CareerPathI|
|--Clustered Index Scan(OBJECT [PDMS].[dbo].[CareerPath].[PK_CareerPath]))|--Hash Match(Right Outer Join, HASH [Rank].[RankID],
|
[Rank].[RankID]=[EmployeeDemographic].[RankID] AND
--Clustered Index Scan(OBJECT [PDMS].[dbo].[Rank].[PK_Rank]))|--Hash Match(Right Outer Join, |
[Organization].[Companycode])=([EmployeeDemographic].[CompanyCode]
[Organization].[Companycode]=[EmployeeDemographic].[CompanyCod
--Index Scan(OBJECT [PDMS].[dbo].[Organization].[IX_Organization]))--Merge Join(Inner Join, MERGE [Metric].[UPN],[Metric].[ProfileYear])=([PerformanceLog].[UPN], |
[PerformanceLog].[ProfileYear]=[Metric].[ProfileYear] AND|
--Compute Scalar(DEFINE [Metric].[LearningAPAhours]=isnull([Metric].[AuthorHours]
|
|
|--Clustered Index Scan(OBJECT [PDMS].[dbo].[Metric].[PK_Metrics]), ORDERED FORWARD)--Merge Join(Inner Join, MERGE [EmployeeDemographic].[UPN],[EmployeeDemographic].[ProfileYear])=([PerformanceLog].[UPN], |
[EmployeeDemographic].[ProfileYear]=[PerformanceLog].[ProfileY
--Sort(ORDER BY [EmployeeDemographic].[UPN] ASC,[EmployeeDemographic].[ProfileYear] ASC)) |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=[EmployeeDemographic].[First
|
|
|--Clustered Index Scan(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_
|
Convert(isnull([EmployeeDemographic].[Executive], 0))=0))|
--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))|--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))| |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))| | |--Sort(ORDER BY [PerformanceLog].[UPN] ASC,[PerformanceLog].[ProfileYear] ASC)) | | | |--Hash Match(Right Outer Join, HASH [ExecutivePromotion].[PLID])=([PerformanceLog].[PLId]))| | | |--Index Scan(OBJECT [PDMS].[dbo].[ExecutivePromotion].[IX_ExecutivePromotion]))| | | |--Hash Match(Right Outer Join, HASH [EmployeeDemographic].[UPN],
|
[PerformanceLog].[YearEndCounselorSignUPN]=[EmployeeDemographi|
| | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | |--Clustered Index Scan(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_
|
|
| | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | |--Bookmark Lookup(BOOKMARK [Bmk1032]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[YearEndCounseleeSignUPN],
|
|
| | | |--Hash Match(Right Outer Join, HASH [EmployeeDemographic].[UPN],
|
[PerformanceLog].[MidYearCounselorSignUPN]=[EmployeeDemographi|
| | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | |--Clustered Index |
[PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_|
| | | | |--Hash Match(Right Outer Join, HASH [EmployeeDemographic].[UPN],
|
[PerformanceLog].[MidYearCounseleeSignUPN]=[EmployeeDemographi|
| | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | |--Clustered Index |
[PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_|
| | | | |--Hash Match(Right Outer Join, HASH [EmployeeDemographic].[UPN],
|
[PerformanceLog].[PlanCounselorSignUPN]=[EmployeeDemographic].|
| | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | --Clustered Index Scan(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_
|
|
| | | | |--Hash Match(Right Outer Join, HASH [EmployeeDemographic].[UPN],
|
[PerformanceLog].[PlanCounseleeSignUPN]=[EmployeeDemographic].|
| | | | --Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
[PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_|
| | | | |--Hash Match(Right Outer Join, HASH [EmployeeDemographic].[UPN],
|
[EmployeeDemographic].[TeamLeaderUPN]=[EmployeeDemographic].[U
[EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
[PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_
[EmployeeDemographic].[UPN],
[PerformanceLog].[UPN]=[EmployeeDemographic].[UPN] AND
[EmployeeDemographic].[UPN] ASC,|
--Clustered Index Scan(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic_
|
[PerformanceLog].[UPN] ASC,
--Compute Scalar(DEFINE [PerformanceLog].[PLCompleted]=If(((((Convert([PerformanceLog].[PlanCounseleeSign])=1 AND |
|
--Clustered Index Scan(OBJECT [PDMS].[dbo].[PerformanceLog].[PK_PL]))| | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[YearEndCounseleeSign|
| | |--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]),
|
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]
| | |--Assert(WHERE If ([Expr1382]>1) then 0 elseNULL)) | | |--Stream Aggregate(DEFINE [Expr1382]=Count(*),
|
|
| | |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
|
| | |--Bookmark Lookup(BOOKMARK [Bmk1044]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
| | |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND
| |--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear],[PerformanceLog].[UPN]), |
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]
| |--Assert(WHERE If ([Expr1384]>1) then 0 else NULL))| |--Stream Aggregate(DEFINE [Expr1384]=Count(*),[Expr1385]=ANY([Target].[SalesGoal]))) | |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
| |--Bookmark Lookup(BOOKMARK [Bmk1050]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))| | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
| |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND
|--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear],[PerformanceLog].[UPN]), |
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]
|--Assert(WHERE If ([Expr1386]>1) then 0 else NULL))|--Stream Aggregate(DEFINE [Expr1386]=Count(*),[Expr1387]=ANY([Target].[UtilizationGoal]))) |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
|--Bookmark Lookup(BOOKMARK [Bmk1056]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))| |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
|--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND
--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear],[PerformanceLog].[UPN]), |
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]
--Assert(WHERE If ([Expr1388]>1) then 0 else NULL))--Stream Aggregate(DEFINE [Expr1388]=Count(*),[Expr1389]=ANY([Target].[RevenueManagedGoal]))) --Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
--Bookmark Lookup(BOOKMARK [Bmk1062]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))|--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND
--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),SEEK [Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND
|
|
--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]),
|
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]
--Assert(WHERE If ([Expr1358]>1) then 0 elseNULL)) --Stream Aggregate(DEFINE [Expr1358]=Count(*),
|
--Filter(WHERE Convert([PerformanceLog].[ProfileYear])=Convert([PerformanceLog].[ProfileYear])-1)) --Index Spool(SEEK [PerformanceLog].[UPN]=[PerformanceLog].[UPN]))--Clustered Index Scan(OBJECT [PDMS].[dbo].[PerformanceLog].[PK_PL]))
|
|
--Compute Scalar(DEFINE [Expr1073]=isnull([EmployeeDemographic].[UPN], ''),
|
|
--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))--Nested Loops(Left Outer Join, OUTER REFERENCES [EmployeeDemographic].[UPN],
|
|--Bookmark Lookup(BOOKMARK [Bmk1004]),OBJECT [PDMS].[dbo].[ExecutivePromotion] AS [EP]))| |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[PLId]))| |--Compute Scalar(DEFINE [Expr1036]=Convert([PerformanceLog].[PlanCounseleeSignTim
|
|
| | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | |--Bookmark Lookup(BOOKMARK [Bmk1014]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | |--Nested Loops(Left Outer Join, OUTER REFERENCES [EmployeeDemographic].[ProfileYear],
|
|
| | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | |--Bookmark Lookup(BOOKMARK [Bmk1012]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | |--Nested Loops(Left Outer Join, OUTER |
[EmployeeDemographic].[ProfileYear],|
| | | |--Nested Loops(Left Outer Join, OUTER |
[EmployeeDemographic].[CareerPathID]))|
| | | | --Nested Loops(Left Outer Join, OUTER REFERENCES [EmployeeDemographic].[RankID],
|
|
| | | | | --Nested Loops(Left Outer Join, OUTER REFERENCES [EmployeeDemographic].[CompanyCode]))| | | | | |--Nested Loops(Inner Join) | | | | | | |--Nested Loops(Inner Join) | | | | | | | |--Compute Scalar(DEFINE [Metric].[LearningAPAhours]=isnull([Metric].[AuthorHours]
|
|
| | | | | | | | |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Metric].[PK_Metrics]),
|
[Metric].[UPN]='1601352' AND [Metric].[ProfileYear]='2003')|
| | | | | | | --Filter(WHERE Convert(isnull([EmployeeDemographic].[Executive],0))=0)) | | | | | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=[EmployeeDemographic].[First
|
|
| | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1000]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))| | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]='1601352' AND|
| | | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))| | | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))| | | | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))| | | | | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]))| | | | | | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[PLId]))| | | | | | | | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1032]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[YearEndCounselorSignUPN],
|
|
| | | | | | | | | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | | | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1030]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | | | | | | |--Nested Loops(Left Outer Join, OUTER |
[PerformanceLog].[YearEndCounseleeSignUPN],|
| | | | | | | | | | | | --Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | | | | | | | | | --Bookmark Lookup(BOOKMARK [Bmk1028]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))| | | | | | | | | | | | | --Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[MidYearCounselorSignUPN],
|
[EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
[Bmk1026]),
[PDMS].[dbo].[EmployeeDemographic]))|
--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[MidYearCounseleeSignUPN],
|
|
--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|--Bookmark Lookup(BOOKMARK [Bmk1024]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))| |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[PlanCounselorSignUPN],
|
|
| | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
| | | |--Bookmark Lookup(BOOKMARK [Bmk1022]),OBJECT [PDMS].[dbo].[EmployeeDemographic]))| | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [PerformanceLog].[PlanCounseleeSignUPN],
|
|
| | | | |--Compute Scalar(DEFINE [EmployeeDemographic].[Name]=EmployeeDemographic.[FirstNa
|
|
| | | | | |--Bookmark Lookup(BOOKMARK [Bmk1020]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | |--Nested Loops(Left Outer Join, OUTER REFERENCES [EmployeeDemographic].[ProfileYear],
|
|
| | | | | | |--Nested Loops(Inner Join) | | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1018]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]='1601352' AND|
| | | | | | | |--Compute Scalar(DEFINE [PerformanceLog].[PLCompleted]=If
|
|
| | | | | | | --Clustered Index Scan(OBJECT [PDMS].[dbo].[PerformanceLog].[PK_PL]),WHERE [PerformanceLog].[UPN]='1601352' AND
|
|
| | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[EmployeeDemographic].[TeamLeaderUPN]|
| | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[PlanCounseleeSignUPN|
| | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[PlanCounselorSignUPN|
--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[MidYearCounseleeSign
[PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
[EmployeeDemographic].[UPN]=[PerformanceLog].[MidYearCounselorSign|
| | | | | | | | | | | | --Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[YearEndCounseleeSign|
| | | | | | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[YearEndCounselorSign|
| | | | | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[ExecutivePromotion].[IX_ExecutivePromotion]),
|
[ExecutivePromotion].[PLID]=[PerformanceLog].[PLId]) ORDERED|
| | | | | | | | | |--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]),
|
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]|
| | | | | | | | | |--Assert(WHERE If ([Expr1380]>1)then 0 else NULL)) | | | | | | | | | |--Stream Aggregate(DEFINE [Expr1380]=Count(*),
|
|
| | | | | | | | | |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
|
| | | | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1042]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
| | | | | | | | | |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND|
| | | | | | | | |--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]),
|
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]|
| | | | | | | | |--Assert(WHERE If ([Expr1382]>1) then 0else NULL)) | | | | | | | | |--Stream Aggregate(DEFINE [Expr1382]=Count(*),
|
|
| | | | | | | | |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
|
| | | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1048]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
| | | | | | | | |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND|
| | | | | | | |--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]),
|
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]|
| | | | | | | |--Assert(WHERE If ([Expr1384]>1) then 0 elseNULL)) | | | | | | | |--Stream Aggregate(DEFINE [Expr1384]=Count(*),
|
|
| | | | | | | |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
|
| | | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1054]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
| | | | | | | |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND|
| | | | | | |--Hash Match(Cache, HASH [PerformanceLog].[ProfileYear], [PerformanceLog].[UPN]),
|
[PerformanceLog].[ProfileYear]=[PerformanceLog].[ProfileYear]|
| | | | | | |--Assert(WHERE If ([Expr1386]>1) then 0 elseNULL)) | | | | | | |--Stream Aggregate(DEFINE [Expr1386]=Count(*),
|
|
| | | | | | |--Nested Loops(Inner Join, OUTER REFERENCES [EmployeeDemographic].[CareerPathID],
|
|
| | | | | | |--Bookmark Lookup(BOOKMARK [Bmk1060]),
|
[PDMS].[dbo].[EmployeeDemographic]))|
| | | | | | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[PK_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[PerformanceLog].[UPN] AND|
| | | | | | |--Clustered Index Seek(OBJECT [PDMS].[dbo].[Target].[PK_Target]),
|
[Target].[CareerPathID]=[EmployeeDemographic].[CareerPathID] AND|
| | | | | |--Index Seek(OBJECT [PDMS].[dbo].[Organization].[IX_Organization]),
|
[Organization].[Companycode]=[EmployeeDemographic].[CompanyCode])|
| | | | | --Clustered Index Seek(OBJECT [PDMS].[dbo].[Rank].[PK_Rank]),SEEK [Rank].[RankID]=[EmployeeDemographic].[RankID] AND
|
|
| | | | --Clustered Index Seek(OBJECT [PDMS].[dbo].[CareerPath].[PK_CareerPath]),
|
[CareerPath].[CareerPathID]=[EmployeeDemographic].[CareerPathID])|
| | | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[EmployeeDemographic].[CounselorUPN]|
| | |--Index Seek(OBJECT [PDMS].[dbo].[EmployeeDemographic].[IX_EmployeeDemographic]
|
[EmployeeDemographic].[UPN]=[EmployeeDemographic].[TeamLeaderUPN]|
| |--Index Seek(OBJECT [PDMS].[dbo].[ExecutivePromotion].[IX_ExecutivePromotion]
|
[EP].[PLID]=[PerformanceLog].[PLId]) ORDERED FORWARD)|
|--Clustered Index Seek(OBJECT [PDMS].[dbo].[MetricSummary].[PK_ExecutivePromotionMetricSu
|
[ms].[UPN]=[EmployeeDemographic].[UPN] AND|
--Table Spool --Assert(WHERE If ([Expr1356]>1) then 0 else NULL))--Stream Aggregate(DEFINE [Expr1356]=Count(*),[Expr1357]=ANY([PerformanceLog].[YearEndRating]))) --Clustered Index Scan(OBJECT [PDMS].[dbo].[PerformanceLog].[PK_PL]),
|
[PerformanceLog].[UPN]=[PerformanceLog].[UPN] AND
#3
| |||
| |||
|
|
SELECT * FROM vwEmployee where EmpID = 12 Execution Time: 50 seconds SELECT * FROM tblEmployee INNER JOIN Country ON EmpCountryID = CountryID LEFT OUTER JOIN Address ON EmpAddID = AddID WHERE EmpID = 12 Execution Time: 2 Seconds Thanks in advance for the help! |
#4
| |||
| |||
|
|
Looks like there was a text limitation when I tried to insert the execution plan for both queries. But looking at the query plan I can see that there is significant difference in what is happening when I do the query off of the view and when I do the query not using the view but the SQL to the view. |
|
The select using just the SQL incurred 86% of the cost doing a clustered index scan against the table. This query took less than a second to run. Is there anything I can do to force the view to do the same as the SQL? |
![]() |
| Thread Tools | |
| Display Modes | |
| |