Oracle Good Hints
Question: Could you share your good hints list please?
Some Oracle people say that there are "good" and bad" hints, but I
don't agree that some hints like the ordered hint belong on
the bad hint list.
the Oracle optimizer always made correct guesses
about the size of internal result sets, hints would
be far less common, but make no mistake, it's
impossible for any software product to always make
the correct guess, based on the limited information
in the data dictionary.
I have the
ordered hint on my good hint
list because there are times when I know better than
the optimizer about the future state of the tables,
and in cases where the is one, and only one optimal
table join order, the ordered hint is a good hint
because it can save the optimizer a huge amount of
processing at parse time, especially for SQL that
joins more than 10 tables.
Good hint or bad hint, hints as a last-resort and your
should always try to
find the rot cause of your suboptimal plan
(stale/missing statistics, wrong optimizer_mode),
When the optimizer makes
a mistake, it's very tempting to add a "good" hint,
and move the SQL into production. In practice,
while your sub-optimal SQL is not a huge issue, it
is a symptom of a much larger issue, and fixing your
execution plan may also have the side effect of
improving the execution plans of thousands of other
There are "good" hints, those that help the
optimizer make a better decision.
The global optimizer mode hints (all_rows,
first_rows_1, first_rows_10, first_rows_100,
first_rows_1000) are good hints because they
are used when the majority of the SQL workload is
optimal, but there are "outlier" SQL that needs a
different optimizer mode.
The only exceptions are hints that give "a priori" information
to the CBO like these good hints:
Don Burleson good hint list:
Of course, you could argue that the CBO would not need some good hints
(e.g. number of rows returned by query, table join order, etc.), but
sometimes there is no substitute for a-priori knowledge.
you like Oracle tuning, you may enjoy my bestselling book
Oracle Tuning: The Definitive Reference",
with over 900 pages of BC's favorite tuning tips & scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts.