push_subq hint tips
Oracle Database Tips by Donald BurlesonApril 2, 2015
Question: I have been reading about the push_subq
hint. I am currently on an older version of Oracle but am
interested in upgrading but I want to get my system tuned first.
How can the push_subq hint help me with tuning my Oracle
subqueries? Where do I put the push_subq hint to make it
most effective? Finally, Is it true that push_subq will
behave differently after my upgrade? and where do I use push_subq to tune Oracle subqueries?
Answer: I'm going to make the assumption that your
current system is older than Oracle 10g and that your upgrade will be to
10g or higher.
In general, subqueries that are not merged into the
outer query are sometimes executed as the last step in the execution
plan. The push_subq hint is used to force all subqueries
in the query block to be executed at the earliest possible place in the
execution plan. With push_subq, the subqueries are often
executed before the outer query is executed.
You also could use
clause and the
materialize hint, along with the
hint that perform functionality similar to that of the push_subq
If the subquery is
relatively inexpensive and reduces the number of rows significantly,
then use of push_subq can improve the overall performance by evaluating the subquery as
soon as possible.
Note that the push_subq hint has no effect if
the subquery is using a sort merge join, or when the subquery references
a remote table.
Additionally, Oracle suggests the use of push_subq
when there are lots of non-indexed predicates where the majority of them
come out TRUE and there is non-merged subquery that significantly reduces
the number of rows. The benefit of this application of push_subq
is likely to only be with large data volumes that would like benefit from
merging the subquery using
When you upgrade to Oracle 10g and beyond, you will find
that push_subq is much more flexible. With multiple
subqueries, push_subq can be used to run individual subqueries at
specific points earlier or later in the process:
The push_subq hint can be moved into any
subquery to be pushed
The push_subq hint can be combined with the
new qb_name() hint in order to name a specific subquery so it
can be referenced by name. This use of push_subq allows the
naming and pushing of any number of subqueries.
The syntax for the push_subq hint is:
/*+ push_subq [ ( @ qb_name) ] */
Conversely, the no_push_subq hint can be used to
force non-merged queries to be evauated as the last step of the execution