Thursday, September 25, 2014

Which sorting algorithm is used when the DMBS executes an 'ORDER BY" SQL statement?

The answer to my question may depend on which database we are using. My bet is that we can not find the answer from the official documentation of RDBMS, such as Oracle and SQL Server. This is somewhat consistent with SQL as a 4th generation language.

Another similar question is "how can I sort a 10G of data while I have only 4G of memory"?

The answer should be "correlated" to "External Sorting" and "Internal Sorting", and usually beyond the in-memory sorting taught in general algorithm textbook.

Here are the links to two articles:

How things works : SQL Order By Clause

"Implementing Sorting in Database Systems" by GOETZ GRAEFE from Microsoft provides more detailed discussion on the sorting algorithm in DBMS.

No comments:

Post a Comment