A merge join requires both its inputs to appear in sorted order, and quite often it is the sorting that uses more resources than the rest of the operation. Consequently, the first section of this chapter is all about sorting, with the mechanisms and costs of the merge operation appearing only in the latter part of the chapter.
Sorting is a rather special operation that is worth focusing on because it is such a common operation, and yet the actual mechanisms and resource requirements are still not commonly known. Oracle may need to use sorting for
order by clauses,
group by clauses, the
distinct operator, merge joins,
connect by queries, B-tree to bitmap conversions, analytic functions, set operations, index ...