Document Type | Technical Information
Category | Administration
Applicable Product Version | 7FS02PS
Document Number | TADTI186
Overview
This chapter explains the parameters that affect the optimizer when establishing execution plans and the considerations for measuring statistics.
Method
1. Optimizer Statistics Settings
1.1 Data Dictionary
The Data Dictionary views where you can check statistical information are as follows.
ALL_TABLES ALL_INDEXES ALL_TAB_STATISTICS ALL_TAB_COL_STATISTICS ALL_TAB_PARTITIONS ALL_TAB_SUBPARTITIONS ALL_IND_PARTITIONS ALL_IDX_SUBPARTITIONS
Note
For various static views where statistics information can be checked, refer to " Tibero Reference Manual" under "Static View".
1.2 Parameters
Careful consideration is required when setting parameters that affect the optimizer's execution plan. It is important to understand the system and business characteristics of the production environment and determine the most effective settings for the respective tasks.
Settings tested in a development environment may initially be appropriate for the production system, but as usage and duration increase, data characteristics may change. Therefore, parameters should be adjusted and criteria established for optimization of those tasks.
Below is an explanation of parameters that may affect the optimizer.
| Parameter | Description |
|---|---|
| OPTIMIZER_MODE |
Determines the cost calculation behavior of the optimizer with five modes available (default: ALL_ROWS) โข FIRST_ROWS_1 โข FIRST_ROWS_10 โข FIRST_ROWS_100 โข FIRST_ROWS_1000 โข ALL_ROWS
|
| CURSOR_SHARING |
โข EXACT: Uses a plan only if the entire SQL string exactly matches a previously parsed plan. โข FORCE: Converts constants in the SQL string to bind variables so that the same plan can be reused.
|
| _OPT_JOIN_MEMORY_LIMIT |
|
| _USE_DYNAMIC_SAMPLING |
Parameter to enable or disable dynamic sampling (default: Y) โข Y: Use dynamic sampling โข N: Do not use dynamic sampling |
| _DYNAMIC_SAMPLING_CONFIDENCE |
|
| ENABLE_HASH_JOIN ENABLE_MERGE_JOIN ENABLE_IDX_JOIN ENABLE_HASH_JOIN_FULL_OUTER |
|
| ENABLE_HASH_GROUPBY ENABLE_SORT_GROUPBY |
|
| _ENABLE_ISS |
Parameter to enable or disable Index Skip Scan (default: Y) โข Y: Enabled โข N: Disabled; if set to N, index skip scan will not be chosen even if hinted. |
| _OPT_PGROUPBY_PUSH_RATIO |
|
| _OPT_BOUND_SELEC_ADJUST_DEGREE |
|
| _SAMPLE_SCAN_SKIP_BLK |
โข N: Disabled (default) โข Y: Enabled |
| _EX_BLOCK_SAMPLING_LVL |
Parameter to improve block sampling performance. โข N: Disabled (default) โข Y: Enabled |
2. Limitations of Statistics Measurement
2.1 Inaccurate Statistics
Statistics collected by sampling differ from actual data and cannot be considered perfect. Also, previously collected statistics may not remain accurate. If data updates increase suddenly or new objects are created, statistics collection is necessary.
A common reason for inefficient execution plans even with accurate statistics is inaccurate row count estimation. Even with accurate statistics, if inefficient plans are executed, it is a limitation of the statistics, not an error.
For example, when LIKE conditions use %, accurate selectivity prediction is difficult with statistics. In such cases, dynamic sampling can help predict actual values during sampling.
2.2 Histogram Limitations
Because the number of histogram buckets is limited, height-balanced histograms cannot accurately represent distributions of low-frequency values.
Cardinality for values not present in histogram buckets may be inaccurate. When bind variables are used, even with bind peeking enabled, variable values at plan generation and execution may differ, so 100% accuracy cannot be guaranteed.
2.3 Incorrect Cost Estimation
Based on statistics, selectivity and cardinality for conditions and joins are calculated, which are used to compute costs for data access methods, index and join methods (Index, Nested loop, Sort Merge, Hash).
However, current statistics may differ from actual data distribution, and selectivity and cardinality calculations may not match real data.
2.4 Sampling Rate
Generally, higher sampling rates improve statistics accuracy, but accuracy decreases when many null values exist or data distribution is uneven.