|
|
Why a Full Table Scan Is Faster for Accessing Large Amounts of Data ?
Full table scans are cheaper than index range scans when accessing a large fraction
of the blocks in a table. This is because full table scans can use larger I/O calls, and
making fewer large I/O calls is cheaper than making many smaller calls.
The elapsed time for an I/O call consists of two components:
1. Call setup time (head seek time, rotational latency)
2. Data transfer time (typically 10 MB a second or better)
In a typical I/O operation, setup costs consume most of the time. Data transfer time
for an 8-K buffer is less than 1 msec (out of the total time of 10 msec). This means
that you can transfer 128 KB in about 20 msec with a single 128 KB call, as opposed
to needing 160 msec with sixteen 8-KB calls.
Example Full Table Scan Compared to Index Range Scan
Consider a case in which 20% of the blocks in a 10,000-block table are accessed. The
following are true:
DB_FILE_MULTIBLOCK_READ_COUNT = 16
DB_BLOCK_SIZE = 8 K
Number of 8 K I/O calls required for index access = 2,000 (table) + index
Number of 128 K I/O calls required for full table scan = 10,000/16 = 625
Assume that each 8 K I/O takes 10 msec, and about 20 seconds are spent doing
single block I/O for the table blocks. This does not include the additional time to
perform the index block I/O. Assuming that each 128 K I/O takes 20 msec, about
12.5 seconds are spent waiting for the data blocks, with no wait required for any
index blocks. |
|