Chapter 5. Optimizing Sort Operations

In this chapter, we will cover:

  • Sorting—in-memory and on-disk
  • Sorting and indexing
  • Writing top n queries and ranking
  • Using count, min/max, and group-by
  • Avoiding sorting in set operations: union, minus, and intersect
  • Troubleshooting temporary tablespaces

Introduction

In this chapter, we analyze some performance issues related to the most time-consuming operation in the database—sort operations.

In the next few recipes, you will see that sorting is related not only to the order-by clause in an SQL query, but also to other type of statements, such as group by and distinct, set operations, ranking, certain kinds of joins and subqueries, as well as index creation.

In the first recipe, we will see the difference between in-memory ...

Get Oracle Database 11gR2 Performance Tuning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.