[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

SQL Queries run at different performance

Asked by Corey_819 in SQL Server 2005, SQL Query Syntax

Hello and sorry to bother everyone with probably an easy question, but I am stuck. What I have is an Select statement I run in one SQL database and it runs very quick less than a second. However, if I go to the same database schema just more data in the tables and run the exact same query I am running at 9 - to 10 seconds. I have ran the SHOW Plan XML and the one database takes the query down one plan/path and the other one take it down another plan/path. Any thoughts based on what you may see in the plan that I am not.

1st plan takes 9 - to 10 seconds
2nd plan take which is different and the one thing I am not sure why takes less than a second.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
select distinct dbo . CV3BasicObservation . ItemName , dbo . CV3BasicObservation . ArrivalDtm , dbo . CV3BasicObservation . Value from dbo . CV3BasicObservation inner join dbo . CV3ResultCatalogItem on dbo . CV3BasicObservation . ResultItemGUID = dbo . CV3
   |--Stream Aggregate(GROUP BY:([UH1].[dbo].[CV3BasicObservation].[ArrivalDtm], [UH1].[dbo].[CV3BasicObservation].[ItemName], [UH1].[dbo].[CV3BasicObservation].[Value]))                                                                                       
        |--Parallelism(Gather Streams, ORDER BY:([UH1].[dbo].[CV3BasicObservation].[ArrivalDtm] ASC, [UH1].[dbo].[CV3BasicObservation].[ItemName] ASC, [UH1].[dbo].[CV3BasicObservation].[Value] ASC))                                                           
             |--Nested Loops(Inner Join, OUTER REFERENCES:([UH1].[dbo].[CV3CatalogClassTypeValue].[CatalogMasterGUID], [Expr1018]) WITH ORDERED PREFETCH)                                                                                                        
                  |--Sort(ORDER BY:([UH1].[dbo].[CV3BasicObservation].[ArrivalDtm] ASC, [UH1].[dbo].[CV3BasicObservation].[ItemName] ASC, [UH1].[dbo].[CV3BasicObservation].[Value] ASC))                                                                        
                  |    |--Hash Match(Inner Join, HASH:([UH1].[dbo].[CV3ResultCatalogItem].[OrderMasterItemGUID])=([UH1].[dbo].[CV3CatalogClassTypeValue].[CatalogMasterGUID]), RESIDUAL:([UH1].[dbo].[CV3ResultCatalogItem].[OrderMasterItemGUID]=[UH1].[dbo].[CV
                  |         |--Parallelism(Distribute Streams, Broadcast Partitioning)                                                                                                                                                                           
                  |         |    |--Merge Join(Inner Join, MERGE:([UH1].[dbo].[CV3ResultCatalogItem].[GUID])=([UH1].[dbo].[CV3BasicObservation].[ResultItemGUID]), RESIDUAL:([UH1].[dbo].[CV3BasicObservation].[ResultItemGUID]=[UH1].[dbo].[CV3ResultCatalogItem
                  |         |         |--Index Scan(OBJECT:([UH1].[dbo].[CV3ResultCatalogItem].[CV3ResultCatalogItemPK]), ORDERED FORWARD)                                                                                                                       
                  |         |         |--Sort(ORDER BY:([UH1].[dbo].[CV3BasicObservation].[ResultItemGUID] ASC))                                                                                                                                                 
                  |         |              |--Nested Loops(Inner Join)                                                                                                                                                                                           
                  |         |                   |--Index Seek(OBJECT:([UH1].[dbo].[CV3ClientVisit].[CV3ClientVisitPK]), SEEK:([UH1].[dbo].[CV3ClientVisit].[GUID]=[@0]) ORDERED FORWARD)                                                                         
                  |         |                   |--Parallelism(Gather Streams)                                                                                                                                                                                   
                  |         |                        |--Clustered Index Scan(OBJECT:([UH1].[dbo].[CV3BasicObservation].[BasicObservationClustIdx]), WHERE:([UH1].[dbo].[CV3BasicObservation].[ClientVisitGUID]=[@0] AND [UH1].[dbo].[CV3BasicObservation].[Arriva
                  |         |--Index Scan(OBJECT:([UH1].[dbo].[CV3CatalogClassTypeValue].[CV3CatalogClassTypeValuePK]))                                                                                                                                          
                  |--Clustered Index Seek(OBJECT:([UH1].[dbo].[CV3OrderCatalogMasterItem].[CV3OrderCatalogMasterItemPK] AS [CV3OrderCatalogMasterItem]), SEEK:([CV3OrderCatalogMasterItem].[GUID]=[UH1].[dbo].[CV3CatalogClassTypeValue].[CatalogMasterGUID]) ORD
 
 
 
 
select distinct dbo . CV3BasicObservation . ItemName , dbo . CV3BasicObservation . ArrivalDtm , dbo . CV3BasicObservation . Value from dbo . CV3BasicObservation inner join dbo . CV3ResultCatalogItem on dbo . CV3BasicObservation . ResultItemGUID = dbo . CV3
  |--Stream Aggregate(GROUP BY:([Replica_UH1].[dbo].[CV3BasicObservation].[ArrivalDtm], [Replica_UH1].[dbo].[CV3BasicObservation].[ItemName], [Replica_UH1].[dbo].[CV3BasicObservation].[Value]))                                                               
       |--Nested Loops(Inner Join)                                                                                                                                                                                                                              
            |--Index Seek(OBJECT:([Replica_UH1].[dbo].[CV3ClientVisit].[CV3ClientVisitPK]), SEEK:([Replica_UH1].[dbo].[CV3ClientVisit].[GUID]=[@0]) ORDERED FORWARD)                                                                                            
            |--Parallelism(Gather Streams, ORDER BY:([Replica_UH1].[dbo].[CV3BasicObservation].[ArrivalDtm] ASC, [Replica_UH1].[dbo].[CV3BasicObservation].[ItemName] ASC, [Replica_UH1].[dbo].[CV3BasicObservation].[Value] ASC))                              
                 |--Nested Loops(Inner Join, OUTER REFERENCES:([CV3OrderCatalogMasterItem].[GUID]))                                                                                                                                                             
                      |--Sort(ORDER BY:([Replica_UH1].[dbo].[CV3BasicObservation].[ArrivalDtm] ASC, [Replica_UH1].[dbo].[CV3BasicObservation].[ItemName] ASC, [Replica_UH1].[dbo].[CV3BasicObservation].[Value] ASC))                                           
                      |    |--Nested Loops(Inner Join, OUTER REFERENCES:([Replica_UH1].[dbo].[CV3ResultCatalogItem].[OrderMasterItemGUID]))                                                                                                                     
                      |         |--Nested Loops(Inner Join, OUTER REFERENCES:([Replica_UH1].[dbo].[CV3BasicObservation].[ResultItemGUID]))                                                                                                                      
                      |         |    |--Clustered Index Scan(OBJECT:([Replica_UH1].[dbo].[CV3BasicObservation].[BasicObservationClustIdx]), WHERE:([Replica_UH1].[dbo].[CV3BasicObservation].[ClientVisitGUID]=[@0] AND [Replica_UH1].[dbo].[CV3BasicObservation
                      |         |    |--Index Seek(OBJECT:([Replica_UH1].[dbo].[CV3ResultCatalogItem].[CV3ResultCatalogItemPK]), SEEK:([Replica_UH1].[dbo].[CV3ResultCatalogItem].[GUID]=[Replica_UH1].[dbo].[CV3BasicObservation].[ResultItemGUID]) ORDERED FOR
                      |         |--Clustered Index Seek(OBJECT:([Replica_UH1].[dbo].[CV3OrderCatalogMasterItem].[CV3OrderCatalogMasterItemPK] AS [CV3OrderCatalogMasterItem]), SEEK:([CV3OrderCatalogMasterItem].[GUID]=[Replica_UH1].[dbo].[CV3ResultCatalogIte
                      |--Clustered Index Seek(OBJECT:([Replica_UH1].[dbo].[CV3CatalogClassTypeValue].[MasterAndClassTypeClustIdx]), SEEK:([Replica_UH1].[dbo].[CV3CatalogClassTypeValue].[CatalogMasterGUID]=[Replica_UH1].[dbo].[CV3OrderCatalogMasterItem].[GU
 
Loading Advertisement...
 
[+][-]10/26/09 04:32 PM, ID: 25668070Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/09 04:36 PM, ID: 25668093Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/26/09 05:09 PM, ID: 25668254Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: SQL Server 2005, SQL Query Syntax
Sign Up Now!
Solution Provided By: DanielWilson
Participating Experts: 1
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625