rbo下針對表與表之間的連線執行計劃的確定原則!
需要注意的一句話是:
Usually, the optimizer does not consider the order in which tables appear in the FROM
clause when choosing an execution plan.
Choosing Execution Plans for Joins with the RBO
Note: The following considerations apply to both the cost-based and rule-based approaches:
|
With the rule-based approach, the optimizer performs the following steps to choose an execution plan for a statement that joins R tables:
- The optimizer generates a set of R join orders, each with a different table as the first table. The optimizer generates each potential join order using this algorithm:
- To fill each position in the join order, the optimizer chooses the table with the most highly ranked available access path according to the ranks for access paths described in "Understanding Access Paths for the RBO". The optimizer repeats this step to fill each subsequent position in the join order.
- For each table in the join order, the optimizer also chooses the operation with which to join the table to the previous table or row source in the order. The optimizer does this by ranking the sort-merge operation as access path 12 and applying these rules:
- If the access path for the chosen table is ranked 11 or better, then the optimizer chooses a nested loops operation using the previous table or row source in the join order as the outer table.
- If the access path for the table is ranked lower than 12, and if there is an equijoin condition between the chosen table and the previous table or row source in join order, then the optimizer chooses a sort-merge operation.
- If the access path for the chosen table is ranked lower than 12, and if there is not an equijoin condition, then the optimizer chooses a nested loops operation with the previous table or row source in the join order as the outer table.
- The optimizer then chooses among the resulting set of execution plans. The goal of the optimizer's choice is to maximize the number of nested loops join operations in which the inner table is accessed using an index scan. Because a nested loops join involves accessing the inner table many times, an index on the inner table can greatly improve the performance of a nested loops join.
Usually, the optimizer does not consider the order in which tables appear in the
FROM
clause when choosing an execution plan. The optimizer makes this choice by applying the following rules in order:- The optimizer chooses the execution plan with the fewest nested-loops operations in which the inner table is accessed with a full table scan.
- If there is a tie, then the optimizer chooses the execution plan with the fewest sort-merge operations.
- If there is still a tie, then the optimizer chooses the execution plan for which the first table in the join order has the most highly ranked access path:
- If there is a tie(平局,不分勝負) among multiple plans whose first tables are accessed by the single-column indexes access path, then the optimizer chooses the plan whose first table is accessed with the most merged indexes.
- If there is a tie among multiple plans whose first tables are accessed by bounded range scans, then the optimizer chooses the plan whose first table is accessed with the greatest number of leading columns of the composite index.
- If there is still a tie, then the optimizer chooses the execution plan for which the first table appears later in the query's
FROM
clause.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1003295/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 表連線 篩選欄位執行計劃不正確Oracle
- 分割槽表與堆表執行計劃的不同
- 表與表之間連線式on,using以及自然連線的區別
- 表的連線是指在一個SQL語句中通過表與表之間的關連SQL
- 表連線的執行步驟
- 執行計劃執行步驟原則
- Oracle訪問表的執行計劃Oracle
- 通過鎖定表的統計資訊來穩定sql的執行計劃SQL
- 表挪動儲存空間後,對之上的sql的執行計劃的影響的探究SQL
- local管理的表空間下autoallocate方式extent的分配原則
- 計算表掃描中執行計劃的COST
- oracle分割槽表執行計劃Oracle
- 如何縮小專案計劃與執行之間的差距?
- 資料表的設計原則
- Sqlserver執行計劃中表的四種連線方式SQLServer
- TOAD檢視執行計劃表
- MySQL 5.5 檢視分割槽表的執行計劃MySql
- 使用Disql執行表空間還原的複雜用法SQL
- CPA二十四--編制中期報表時確認與計量的原則(轉載)
- 新特性解讀 | 針對使用者定製不同格式執行計劃
- 怎樣得到準確的執行計劃
- oracle查詢語句執行計劃中的表消除Oracle
- oracle 各種表間連線Oracle
- mysql 基於規則的執行計劃MySql
- SQL的外連線對內部表的限制SQL
- 11GR2的delete全表的執行計劃變化delete
- 看執行計劃是否正確
- 使用聯機SQL執行表空間還原(一)SQL
- DM7使用Disql執行表空間還原SQL
- DM7使用DMRMAN執行表空間還原
- 表空間管理之bigfile表空間設定
- Mysql SQL最佳化系列之——執行計劃連線方式淺釋MySql
- mysql 基於規則的執行計劃(二)MySql
- UNDO表空間自動調優原則
- 執行計劃-資料訪問方式(全表掃描與4種索引的方式)索引
- ORACLE表連線方式的分析與優化Oracle優化
- set autotrace on 產生不準確的執行計劃
- MySQL分庫分表的原則MySql