Exploring optimizer hints
In this recipe, we will see how to suggest (to the optimizer) the strategy to adopt for choosing the best execution plan, using optimizer hints.
Note
The use of optimizer hints is a trick and should be considered only when no solution seems to work. The query optimizer is designed to choose the best execution plan, based on many different considerations, so it's very important to keep updated statistics to help the query optimizer in doing its work.
How to do it...
The following steps will explore optimizer hints:
- Connect the database to the
SH
schema:CONNECT sh@TESTDB/sh
- Set the auto-trace functionality in SQL*Plus to see only the execution plan without executing the queries:
SET AUTOT TRACE EXP
- Select some records from ...
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.