QuestionQ100

VerifiedTuning SQL Statements

You must write a statement that returns the ten most recent sales. Review this statement:

Question Image

Users report that the query runs too slowly. Review the statement’s current execution plan:

Question Image

What must you do to reduce execution time, and why?

Explanation

An index on SALES.TIME_ID can supply rows in the ORDER BY sequence, avoiding the SORT ORDER BY STOPKEY over the joined result set and allowing top-N processing to stop after the required 10 rows. The matching estimated and actual row counts show no evidence that stale statistics are driving the plan. Oracle documents that an index capable of satisfying an ORDER BY lets the optimizer avoid a separate sort.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!