Oracle knows that the external environment has a profound
impact on SQL performance, and the Oracle cost-based optimizer now has the
ability to consider real-world timings for multiblock reads (mreadtim)
and sequential read I/O times (sreadtim) within the
dbms_stats.gather_system_stats procedure.
Oracle has two types of CBO statistics for estimating disk
read times workload and "noworkload" statistics. The ?noworkload? statistics
gather data by submitting random reads against all data files, while the
workload statistics increments internal counters to measure database I/O
activity.
- Noworkload statistics - These include
CPUSPEEDNW, IOSEEKTIM and IOTFRSPEED.
- Workload statistics - These are gathered by
dbms_stats.gather_system_stats and include SREADTIM, MREADTIM, CPUSPEED,
MBRC, MAXTHR, and SLAVETHR represent workload statistics.
If both workload and noworkload statistics are available,
the optimizer uses the workload statistics in hopes of getting the ?best?
execution plan for the SQL. You can run this query to see the current values
for your database:
SQL> select sname,
pname, pval1
from sys.aux_stats$;
SNAME PNAME PVAL1
------------- --------- -------
SYSSTATS_INFO STATUS
SYSSTATS_INFO DSTART
SYSSTATS_INFO DSTOP
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 502.005
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM 7.618
SYSSTATS_MAIN MREADTIM 14.348
SYSSTATS_MAIN CPUSPEED 507
SYSSTATS_MAIN MBRC 6
SYSSTATS_MAIN MAXTHR 32768
SYSSTATS_MAIN SLAVETHR
13 rows selected.
Oracle workload statistics that are gathered with
dbms_stats.gather_system_stats now gather real-workload I/O performance
metrics:
-
SREADTIM - Single block read time in milliseconds
-
MREADTIM - Multiblock read time in ms
-
CPUSPEED - CPU speed
-
MBRC - Average blocks read per
multiblock read (see
db_file_multiblock_read_count)
-
MAXTHR - Maximum I/O throughput (for OPQ only)
-
SLAVETHR - OPQ Factotum (slave)
throughput (OPQ only)
When the multiblock read time is
less than single block disk read time (mreadtim <= sreadtim), then the query
plan costing will not use the workload statistics.
The
Oracle 10g Performance Tuning Guide notes that the timing of the workload
sample is important and that you want to run your samples during a time when you
are performing legitimate multiblock reads (or, stage a workload that performs
full-table scans):
During the gathering process of workload statistics, it
is possible that mbrc and mreadtim will not be gathered if no table scans
are performed during serial workloads, as is often the case with OLTP
systems.
On the other hand, FTS occur frequently on DSS systems
but may run parallel and bypass the buffer cache. In such cases, sreadtim
will still be gathered since index lookup are performed using the buffer
cache.
The docs also note that :"bad
timing" of a system statistics sample can cause less than optimal estimates for
the timings of full-table scan I/O:
If Oracle cannot gather or validate gathered mbrc or
mreadtim, but has gathered sreadtim and cpuspeed, then only sreadtim and
cpuspeed will be used for costing.
FTS cost will be computed using analytical algorithm
implemented in previous releases. Another alternative to computing mbrc and
mreadtim is to force FTS in serial mode to allow the optimizer to gather the
data.