[prev] 7 [next]

The Sort Operation

Sorting is explicit in queries only in the order by clause

select * from Students order by name;

Sorting is used internally in other operations:

  • eliminating duplicate tuples for projection
  • ordering files to enhance select efficiency
  • implementing various styles of join
  • forming tuple groups in group by
Sort methods such as quicksort are designed for in-memory data.

For large data on disks, use external sorts such as merge sort.