Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

do Distinct, Group By, Order By & Union (without All) Expand / Collapse
Author
Message
Posted Wednesday, May 8, 2013 7:05 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 10:31 AM
Points: 363, Visits: 660
all take the same hit on Sort?
Is there any way to mitigate that or conditions that make one cheaper than another forcing uniqueness?
thanks very much
drew
Post #1450858
Posted Wednesday, May 8, 2013 9:36 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 7:16 PM
Points: 298, Visits: 715
Hi,


This resource, Logical Query Processing , from Itzik Ben-Gan's book will help you understand what is going on behind the scenes.



But if you want to know for sure then run your particular scenario with the execution plan on and compare results.


Regards,
Bevan Keighley
Post #1450873
Posted Thursday, May 9, 2013 4:43 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 15, 2013 6:32 AM
Points: 34, Visits: 70
drew.georgopulos (5/8/2013)
all take the same hit on Sort?
Is there any way to mitigate that or conditions that make one cheaper than another forcing uniqueness?
thanks very much
drew



I don't think there is any alternative(other than mentioned) way to get unique data.
Post #1451006
Posted Thursday, May 9, 2013 6:05 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 10:31 AM
Points: 363, Visits: 660
thanks very much...the execution plan is what informed me about where the query was so costly, but i was surprised to find that all the alternatives boiled down to 96% spent on Sort, (divided sometimes in different branches depending on where i put which operator(s)) but Sort was always the elephant in the room!
that was a great diagram, i learned that ages ago but never saw it so cleanly diagrammed, so thanks a lot for pointing it out.
drew
Post #1451061
Posted Thursday, May 9, 2013 6:52 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:14 AM
Points: 6,890, Visits: 14,253
suneet.mlvy (5/9/2013)
drew.georgopulos (5/8/2013)
all take the same hit on Sort?
Is there any way to mitigate that or conditions that make one cheaper than another forcing uniqueness?
thanks very much
drew



I don't think there is any alternative(other than mentioned) way to get unique data.


It depends upon the shape of the data. If there are relatively few distinct values in the set, then Paul White's super-fast distinct, which uses seeks instead of sorts, can execute many times faster than native DISTINCT.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1451087
Posted Thursday, May 9, 2013 2:50 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 10:31 AM
Points: 363, Visits: 660
Holy Good Night!
I never would have thought of that, and it is breathtaking!
Thanks so much for telling me about it, I really appreciate it.
drew
Post #1451326
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse