|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 3:18 PM
Points: 37,744,
Visits: 30,025
|
|
karthik M (3/8/2013) whereever the optimizer sort the data, it sould use some algorothim to do this operation? Right?
My question is simple, is there any alogrithm used for ORDER BY clause or not by the optimizer?
As I said earlier, the optimiser won't use any algorithm. The optimiser optimises queries, it doesn't run them.
Sure there will be algorithms used for order by (and for every single other operation given the definition of 'algorithm'). Why does it matter which one SQL uses?
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 2:56 AM
Points: 2,008,
Visits: 2,469
|
|
Why does it matter which one SQL uses?
I am asking "Out of Curiosity" to know the algorithm used by the engine.
karthik
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 2:56 AM
Points: 2,008,
Visits: 2,469
|
|
is this a secret maintened by microsoft ?
karthik
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 3:41 AM
Points: 13,383,
Visits: 25,189
|
|
karthik M (3/8/2013)
is this a secret maintened by microsoft ? 
Short answer, yes.
Longer answer, Microsoft publishes some of the internals because it helps people understand how or why things are occurring within the system. Also, some people figure out some of the internals through trial & error, investigation, or even putting a debugger on the system. But all the internals are not published. There are lots and lots of proprietary information that Microsoft has inside the code that they just don't feel the need to share. The exact sorting process used by the query engine (not the optimizer) is not something I've seen documentation on, so I suspect it's protected.
---------------------------------------------------- "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt The Scary DBA Author of: SQL Server 2012 Query Performance Tuning SQL Server 2008 Query Performance Tuning Distilled and SQL Server Execution Plans
Product Evangelist for Red Gate Software
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 10:22 AM
Points: 1,037,
Visits: 7,695
|
|
karthik M (3/8/2013)
is this a secret maintened by microsoft ? 
In the sense that it's proprietary information that they've chosen not to share and SQL Server is a closed source product, yes.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 3:18 PM
Points: 37,744,
Visits: 30,025
|
|
karthik M (3/8/2013)
Why does it matter which one SQL uses? I am asking "Out of Curiosity" to know the algorithm used by the engine.
So download the public symbols, attach a debugger to SQL Server and walk through what runs when you order a query.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, May 22, 2013 1:30 AM
Points: 803,
Visits: 2,124
|
|
I would suspect that there's some sort of internal algorithm used to select the best sort algorithm for a given data set, based on the data type, data volumes etc
_________________________________________________________________________ SSC Guide to Posting and Best Practices
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 8:43 PM
Points: 6,998,
Visits: 13,952
|
|
Besides - all of those sorts methods you mentioned presume a flat list structure. The internals for how tables are structured are anything but flat.
In short - I suspect the actual answer is "none of the above".
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 22, 2013 8:32 AM
Points: 48,
Visits: 201
|
|
Matt Miller (#4) (3/8/2013) Besides - all of those sorts methods you mentioned presume a flat list structure. The internals for how tables are structured are anything but flat.
In short - I suspect the actual answer is "none of the above".
I'd tend to agree with Matt on this - my suspicion is that it will use a heavily optimised hash table in most circumstances but the only people that can give you a definitive answer would be Microsoft. You could try asking on MSDN.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 10:39 AM
Points: 2,556,
Visits: 4,398
|
|
Curiosity is a great thing! Without it, elephants wouldn't have trunks...
What does the Crocodile have for dinner?...

_____________________________________________ "The only true wisdom is in knowing you know nothing" "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!" (So many miracle inventions provided by MS to us...)
How to post your question to get the best and quick help
|
|
|
|