|
By Kim Floss
The Oracle optimizer_mode sets an overall
performance goal for the CBO in terms of throughput versus
response time. In Oracle Database 10g, the default
setting (all_rows), primes the CBO to select for overall best
throughput—the optimizer will choose the plan that delivers
all the rows in a query in the shortest possible overall time.
On the other hand, the first_rows setting will cause the
optimizer to provide fastest response time by choosing the
plan that delivers an initial subset of rows more quickly, and
the remainder of the query in a longer period of time than the
all_rows setting.
The "first_rows_n" setting (new as
of Oracle9i Database) lets you balance the possible
variances in this continuum (throughput versus response) more
directly, by letting you set the number of rows to 1, 10, 100,
or 1000. In Oracle Database 10g, if the query contains
a rownum predicate, the CBO automatically switches to
first_rows_n mode, deriving the value of n from the rownum
predicate.
Another important optimizer
initialization parameter is optimizer_dynamic_sampling.
Statistics on database objects (size of tables, indexes,
number of rows in tables, number of distinct values in
columns, percentage of table below the high-water mark, and so
on) play a key role in estimating costs (see Table 2), and if
the CBO can't find up-to-date statistics to work with during
the cost estimation phase of statement processing, it can
dynamically sample statistical data at that time—if this
parameter is set. The default level in Oracle Database 10g
is 2, which means the CBO will use dynamic sampling on
nonanalyzed tables to collect necessary statistics from them
while optimizing the query.
Optimizer parameters from
the v$sys_optimizer_env from various releases
The optimizer-related parameters can be
set at the session level, or modified for a single SQL
statement by using optimizer hints.
| optimizer_features_enable |
10.1.0 |
9.2.0 |
9.0.1 |
8.1.7 |
| cursor_sharing |
Exact |
exact |
exact |
exact |
| db_file_multiblock_read_count |
8 |
8 |
16 |
16 |
| optimizer_dynamic_sampling |
2 |
1 |
na |
na |
| optimizer_index_caching |
0 |
0 |
0 |
0 |
| optimizer_index_cost_adj |
100 |
100 |
100 |
100 |
| optimizer_mode |
all_rows |
choose |
choose |
choose |
| parallel_ddl_mode |
enabled |
enabled |
enabled |
enabled |
| parallel_dml_mode |
disabled |
disabled |
disabled |
disabled |
| parallel_execution_enabled |
TRUE |
TRUE |
TRUE |
TRUE |
| parallel_query_mode |
enabled |
enabled |
enabled |
enabled |
| parallel_threads_per_cpu |
2 |
2 |
2 |
2 |
| pga_aggregate_targe 24576 KB |
24576 KB |
24576 KB |
24576 KB |
| query_rewrite_enabled |
TRUE |
FALSE |
FALSE |
FALSE |
| query_rewrite_integrity |
enforced |
enforced |
enforced |
enforced |
| skip_unusable_indexes |
TRUE |
FALSE |
FALSE |
FALSE |
| sort_area_retained_size |
0 |
0 |
0 |
0 |
| sort_area_size |
65536 |
65536 |
65536 |
65536 |
| star_transformation_enabled |
FALSE |
FALSE |
FALSE |
FALSE |
| Statistics_level |
typical |
all |
all |
all |
| workarea_size_policy |
auto |
auto |
auto |
auto |
|