OPTIMIZER_MODE、optimizer_index_cost_adj
OPTIMIZER_INDEX_CACHING lets you adjust the behavior of cost-based optimization to favor nested loops joins and IN-list iterators.The cost of executing an index using an IN-list iterator or of executing a nested loops join when an index is used to access the inner table depends on the caching of that index in the buffer cache.You can modify the optimizer's assumptions about index caching for nested loops joins and IN-list iterators by setting this parameter to a value between 0 and 100 to indicate the percentage of the index blocks the optimizer should assume are in the cache
可以理解為在buffer cache裡面找到索引塊的百分比,預設0
OPTIMIZER_INDEX_COST_ADJ lets you tune optimizer behavior for access path selection to be more or less index friendly that is, to make the optimizer more or less prone to selecting an index access path over a full table scan.The default for this parameter is 100 percent, at which the optimizer evaluates index access paths at the regular cost. Any other value makes the optimizer evaluate the access path at that percentage of the regular cost. For example, a setting of 50 makes the index access path look half as expensive as normal
optimizer_index_cost_adj可以理解為把索引掃描的成本轉換為全表掃描的成本百分比,預設100%表示索引掃描成本等價轉換為全表掃描成本。
Oracle在選擇不同的訪問路徑時,會對全表掃描和索引掃描進行比較評估,在比較的時候,Oracle會把索引掃描的成本轉換為全表掃描的成本,和全表掃描的COST進行比較。這個轉換需要一個轉換因子,就是Optimizer_index_cost_adj;
Optimizer_index_cost_adj*(index scan cost)=等價的Full Scan cost
比如oracle算出全表掃描成本為20,索引掃描為30
如果設定optimizer_index_cost_adj等於50,則索引掃描*50%=15=等價的全表掃描為15,這個時候比算出的全表掃描要低,所以走索引掃描。
如果設定optimizer_index_cost_adj等於100,則索引掃描*100%=30=等價的全表掃描為30,這個時候比算出的全表掃描要高,所以走全表掃描
20/30=66.7%,說明臨界值是67%,當大於67%比如100%則走全表掃描,當小於67%比如50%則走索引掃描
10g開始,optimizer_mode替代了以上兩個引數的作用
optimizer_mode=ALL_ROWS更容易走全表掃描
OPTIMIZER_MODE establishes the default behavior for choosing an optimization approach for the instance.
first_rows_n:The optimizer uses a cost-based approach and optimizes with a goal of best response time to return the first n rows (where n = 1, 10, 100, 1000).
all_rows:The optimizer uses a cost-based approach for all SQL statements in the session and optimizes with a goal of best throughput (minimum resource use to complete the entire statement).
OPTIMIZER_MODE:告訴CBO在生成執行計劃的時候的一個方向。
- 以響應時間優先:first_rows_N
要求不考慮代價,最快的返回前N條記錄,N為1,10,100,1000
通常會產生索引掃描,或者nested loop join的執行計劃。
適用於OLTP系統。
- 以吞吐量優先:all_rows
要求以最小資源開銷為目的,返回所有記錄。
通常會產生全表掃描,或者hash join的執行計劃。
適用於DW或者混合系統。
可以理解為在buffer cache裡面找到索引塊的百分比,預設0
OPTIMIZER_INDEX_COST_ADJ lets you tune optimizer behavior for access path selection to be more or less index friendly that is, to make the optimizer more or less prone to selecting an index access path over a full table scan.The default for this parameter is 100 percent, at which the optimizer evaluates index access paths at the regular cost. Any other value makes the optimizer evaluate the access path at that percentage of the regular cost. For example, a setting of 50 makes the index access path look half as expensive as normal
optimizer_index_cost_adj可以理解為把索引掃描的成本轉換為全表掃描的成本百分比,預設100%表示索引掃描成本等價轉換為全表掃描成本。
Oracle在選擇不同的訪問路徑時,會對全表掃描和索引掃描進行比較評估,在比較的時候,Oracle會把索引掃描的成本轉換為全表掃描的成本,和全表掃描的COST進行比較。這個轉換需要一個轉換因子,就是Optimizer_index_cost_adj;
Optimizer_index_cost_adj*(index scan cost)=等價的Full Scan cost
比如oracle算出全表掃描成本為20,索引掃描為30
如果設定optimizer_index_cost_adj等於50,則索引掃描*50%=15=等價的全表掃描為15,這個時候比算出的全表掃描要低,所以走索引掃描。
如果設定optimizer_index_cost_adj等於100,則索引掃描*100%=30=等價的全表掃描為30,這個時候比算出的全表掃描要高,所以走全表掃描
20/30=66.7%,說明臨界值是67%,當大於67%比如100%則走全表掃描,當小於67%比如50%則走索引掃描
10g開始,optimizer_mode替代了以上兩個引數的作用
optimizer_mode=ALL_ROWS更容易走全表掃描
OPTIMIZER_MODE establishes the default behavior for choosing an optimization approach for the instance.
first_rows_n:The optimizer uses a cost-based approach and optimizes with a goal of best response time to return the first n rows (where n = 1, 10, 100, 1000).
all_rows:The optimizer uses a cost-based approach for all SQL statements in the session and optimizes with a goal of best throughput (minimum resource use to complete the entire statement).
OPTIMIZER_MODE:告訴CBO在生成執行計劃的時候的一個方向。
- 以響應時間優先:first_rows_N
要求不考慮代價,最快的返回前N條記錄,N為1,10,100,1000
通常會產生索引掃描,或者nested loop join的執行計劃。
適用於OLTP系統。
- 以吞吐量優先:all_rows
要求以最小資源開銷為目的,返回所有記錄。
通常會產生全表掃描,或者hash join的執行計劃。
適用於DW或者混合系統。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2141984/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Optimizer_mode引數
- 引數OPTIMIZER_MODE
- OPTIMIZER_MODE Initialization Parameter
- 引數 optimizer_index_cost_adjIndex
- 淺談optimizer_mode優化器模式優化模式
- optimizer_index_cost_adj引數的作用Index
- OPTIMIZER_INDEX_COST_ADJ與成本計算Index
- optimizer_index_cost_adj的測試 IIndex
- Oracle 優化引數 optimizer_mode 介紹Oracle優化
- OPTIMIZER_INDEX_CACHING & OPTIMIZER_INDEX_COST_ADJIndex
- 【轉】OPTIMIZER_INDEX_COST_ADJ與成本計算Index
- Oracle控制優化器偏好--optimizer_mode引數Oracle優化
- Oracle 最佳化引數 optimizer_mode 介紹Oracle
- OPTIMIZER_INDEX_CACHING和OPTIMIZER_INDEX_COST_ADJIndex
- 10g中的optimizer_mode引數的取值
- 10G預設optimizer_mode為all_rows
- [zt] OPTIMIZER_INDEX_CACHING和OPTIMIZER_INDEX_COST_ADJIndex
- Oracle9i, 10g 優化模式 OPTIMIZER_MODEOracle優化模式
- Oracle 10g(10.1.0.2)中的OPTIMIZER_INDEX_COST_ADJ(轉)Oracle 10gIndex
- 引數Optimizer_index_cost_adj 對執行計劃的影響Index
- optimizer_index_cost_adj和optimizer_index_caching對CBO的影響Index
- DBA手記 - optimizer_mode影響一個SQL語句是否可以執行SQL
- optimizer_index_caching和optimizer_index_cost_adj兩個引數說明Index
- 當Oracle9i的OPTIMIZER_MODE = FIRST_ROWS時EXP過慢的解決方法Oracle
- 優化模式optimizer_mode為choose,table沒有被分析過,卻採用cbo的幾個原因(zt)優化模式