1Oracle 8 Optimizer Hints
1.1 Using Hints
You can use hints to alter the execution path chosen by the cost-based optimizer. Hintsare embedded within SQL statements, and only modify the execution path for thestatements in which they appear. The start of a hint is indicated by the string.Following a SELECT, DELETE, or UPDATE. A hint’s text is terminated byThe syntax for hints is almost identical to that of comments within SQL – the onlydifference is the addition of the “+” sign to indicate the start of the hint. The “+” cannot be preceded by a space.
If a hint is specified incorrectly, the optimizer will ignore it and will not report an error.In the following sections, you’ll see descriptions of the available hints and examples of their usage. Many of the hints shown in the following sections are referenced in Chapter 11. The operations referenced by the hints are described in the “Operations” sectionearlier in this chapter.
Many of the hints allow you to list specific table names. If you use table aliases in your query, refer to the tables by their aliases within the hints.
The ALL_ROWS hint tells Oracle to optimize the query for the best throughput-that is, tominimize the time it takes for all rows to be returned by the query. This is the defaultaction of the Oracle optimizer, and is appropriate for batch operations. An example isshown in the following listing.The example show in the previouslisting would normally use a NESTED LOOPS operation during
select /*+ ALL_ROWS */COMPANY.Namefrom COMPANY, SALESwhere COMPANY.Company_ID = SALES.Company_IDand SALES.Period_ID =3and SALES.Sales_Tctal>1000;