Top 60 Oracle Blogs

Recent comments

Ignoring hints

A hint is an instruction to the optimizer

This is what’s written in Oracle documentation. Instruction is defined as

a code that tells a computer to perform a particular operation

Which means Oracle CBO must obey the hints and must perform particular operation. The latter is hard to define correctly and explain precisely because it involves the logic of the block-box (what Cost Based Optimizer is). Some of the operations are mentioned in the standard Oracle documentation, some of them scattered across different places, and there are exceptions as usual. I think I’ll list here these cases which could lead to “ignoring hints” with the links to documentation/blogs.

Description Hints affected Reference
The hint has a syntax error, or doesn’t follow DELETE/INSERT/SELECT/MERGE/UPDATE keyword, or conflicts with other hints All
The optimizer ignores FIRST_ROWS in DELETE and UPDATE statement blocks and in SELECT statement blocks that include any blocking operations, such as sorts or groupings FIRST_ROWS
The LEADING hint is ignored if the tables specified cannot be joined first in the order specified because of dependencies in the join graph. If you specify two or more conflicting LEADING hints, then all of them are ignored. If you specify the ORDERED hint, it overrides all LEADING hints. LEADING, ORDERED
If a NO_INDEX hint and an index hint (INDEX, INDEX_ASC,INDEX_DESC, INDEX_COMBINE, or INDEX_FFS) both specify the same indexes, then the database ignores both the NO_INDEX hint and the index hint for the specified indexes and considers those indexes for use during execution of the statement. INDEX*
If two or more query blocks have the same name, or if the same query block is hinted twice with different names, then the optimizer ignores all the names and the hints referencing that query block. QB_NAME
If a hint specifies an unavailable access path, the optimizer ignores it Access path
If the statement uses an alias for the table, then use the alias rather than the table name in the hint Access path
The table name within the hint should not include the schema name if the schema name is present in the statement Access path
For access path hints, Oracle Database ignores the hint if you specify the SAMPLE option in the FROM clause of a SELECT statement Access path
The hints USE_NL & USE_MERGE are ignored if the referenced table is the outer table in the join Join operations
Oracle Database ignores global hints that refer to multiple query blocks ?
Access path and join hints on referenced views are ignored unless the view contains a single table or references an Additional Hints view with a single table. ?
With nonmergeable views, optimization approach and goal hints inside the view are ignored. Access path hints on the view in the top-level query are ignored. ?
If an invalid hint is a valid SQL keyword, it causes other hints to be ignored All
When parallel_instance_group points to a non-existent service name, PARALLEL hint will be ignored PARALLEL
INDEX hint may be “ignored” if materialized query rewrite produces plan with lower cost ?
Transitive closure and join elimination may produce a plan which ignores USE_HASH hint Join operations
Hints in ANSI joins could be ignored due to query transformation and introduction of new query blocks ?
Undocumented limit of 20 chars for query block name causes QB_NAME to be ignored QB_NAME

Unsurprisingly, most of the cases are covered by the documentation. Good to know.
PS. Apart from documentation, an excellent source of information about hinting is presentation and paper Hint on Hints by Jonathan Lewis.