Chapter 11. Sorting, Grouping, and Set Operations
In this chapter we look at improving the performance of SQL operations that require Oracle to order or group data and operations that work on complete sets of data rather than on individual rows.
Oracle might need to sort data as a result of an explicit request to return data in order (for instance, ORDER BY) or as a result of an internal intermediate operation that requires the data to be in sorted order (for instance, the INTERSECT operation). Sorts can consume significant computer resources—especially memory—and have a substantial effect on query performance. Knowing when Oracle performs sorts, ways of avoiding sorts, and how to optimize sorts is, therefore, important when tuning SQL.