 |
|
Fast Full Index Scan
Oracle Tips by Burleson Consulting |
Index full scans are sometimes called fast
full-index scans, which were introduced in Oracle 7.3. There are
some SQL queries that can be resolved by reading the index without
touching the table data. For example, the following query does not
need to access the table rows, and the index alone can satisfy the
query.
select distinct
color,
count(*)
from
automobiles
group by
color;
While some queries have always been able to return the
desired result without touching the table data, Oracle enhanced the
fast full-index scan to make it behave similar to a full-table scan.
Just as Oracle has implemented the initialization parameter
db_file_multiblock_read_count for full-table scans, Oracle
allows this parameter to take effect when retrieving rows for a fast
full-index scan. Since the whole index is accessed, Oracle allows
multiblock reads. Also, a fast full-index scan is capable of using
Oracle parallel query to further speed up the response time.
There is a huge benefit to not reading the
table rows, but there are some requirements for Oracle to invoke the
fast full-index scan.
-
All of the columns required must be specified
in the index. That is, all columns in the select and where clauses
must exist in the index.
-
The query returns more than 10 percent of the
rows within the index. This 10 percent figure depends on the
degree of multiblock reads and the degree of parallelism.
-
You are counting the number of rows in a
table that meet a specific criterion. The fast full-index scan is
almost always used for count(*) operations.
The cost-based optimizer will make the
decision about whether to invoke the fast full-index scan in
accordance with the table and index statistics. You can also
force a fast full-index scan by specifying the index_ffs
hint:select distinct /*+ index_ffs(c,pk_auto) /*
color,
count(*)
from
automobiles
group by
color;
It is not always intuitive whether a fast
full-index scan is the fastest way to service a query, because of
all of the variables involved. Hence, most expert SQL tuners will
time any query that meets the fast full-index scan criteria and see
if the response time improves. Again, this is almost always fastest
with count(*) operations. For counting operations, the fast
full-index scans with parallel_index is clearly the fastest
access method.
Next, let’s examine a very important SQL
operation, the SQL join. It is through the join that Oracle
navigates through the database and presents information from
different tables based on a common column value.
This is an excerpt from "Oracle High-Performance SQL Tuning" by
Donald K. Burleson, published by Oracle Press.