Question:
What is Oracle partition pruning and how does it make my SQL
run faster?
Answer:
Oracle partition pruning is a divided and conquer approach
where Oracle is Partition Aware, excluding any partitions that do
not contain blocks that are needed to satisfy the query result set.
Some DBA's report that
partition pruning can take a SQL query down from
hours to minutes.
Partition pruning is a
very important because the CBO eliminates un-needed partitions when building the
partition access list. You only choose what you need.
Be cause you only access the piece of the
table that contains the data needed by the query, partition pruning
can also dramatically reduce the amount of data retrieved from disk
and reduce processing time, especially for I/O bound databases with
small ram data buffers (db_cache_size).
Partition Pruning Internals
Partition pruning
occurs when a SQL statement involving a partitioned object is
executed and the database recognizes that the selection criteria are
only specific partitions.
This allows the database to access only the relevant
partitions and ignore all partitions that are not necessary for the
SQL statement. In other
words, partition pruning is the act of eliminating, or ignoring,
partitions that are irrelevant to the SQL statement's selection
criteria.
Beginning with Oracle
11g, partition pruning uses bloom filtering instead of subquery
pruning. A bloom filter
essentially tests if an element is a member of a set or not.
In deciding whether to use partition pruning, a bloom filter
uses partition pruning whenever a partitioned object is detected in
the SQL statement. This
enhances the performance of partition pruning because bloom
filtering does not require additional resources. Also, it is not
evaluated as a cost based decision.
Instead, bloom filtering is constantly active as well as
automatically activated for any join with a partitioned object.
This transparent enhancement improves the performance of
partition pruning.
|
|
Get the Complete
Oracle SQL Tuning Information
The landmark book
"Advanced Oracle
SQL Tuning The Definitive Reference" is
filled with valuable information on Oracle SQL Tuning.
This book includes scripts and tools to hypercharge Oracle 11g
performance and you can
buy it
for 30% off directly from the publisher.
|