|
|
|
Oracle Concepts - Index-only tables
Oracle Tips by Burleson Consulting |
Index-only tables
Oracle recognized that a table with an index built on
every column did not require table rows to exist! In other words, Oracle
recognized that by using a special table-access method called an index fast full
scan, the index could be queried without actually touching the data itself.
Oracle codified this idea with its use of index-only
table (IOT) structure. When using an IOT, Oracle does not create the actual
table but instead keeps all of the required information inside the Oracle index.
At query time, the Oracle SQL optimizer recognizes that
all of the values necessary to service the query exist within the index tree, at
which time the Oracle cost-based optimizer has a choice of either reading
through the index tree nodes to pull the information in sorted order or invoke
an index fast full scan, which will read the table in the same fashion as a full
table scan, using sequential prefetch (as defined by the
db_file_multiblock_read_count parameter).
The multiblock read facility allows Oracle to very
quickly scan index blocks in linear order, quickly reading every block within
the index tablespace. Here is an example of the syntax to create an IOT.
CREATE
TABLE emp_iot (
emp_id
number,
ename
varchar2(20),
sal
number(9,2),
deptno
number,
CONSTRAINT pk_emp_iot_index PRIMARY KEY (emp_id) )
ORGANIZATION index
TABLESPACE spc_demo_ts_01
PCTHRESHOLD 20 INCLUDING ename;
Information on IOT and pct_direct_access is available
HERE.
This is an excerpt from the bestselling "Easy
Oracle Jumpstart" by Robert Freeman and Steve Karam (Oracle ACE and Oracle
Certified Master). It?s only $19.95 when you buy it directly from the
publisher
here.
|
If you like Oracle tuning, you may enjoy the new book "Oracle
Tuning: The Definitive Reference", 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. |
|