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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 表的連線是指在一個SQL語句中通過表與表之間的關連SQL
- 執行計劃執行步驟原則
- 通過鎖定表的統計資訊來穩定sql的執行計劃SQL
- 如何縮小專案計劃與執行之間的差距?
- Sqlserver執行計劃中表的四種連線方式SQLServer
- 使用Disql執行表空間還原的複雜用法SQL
- 新特性解讀 | 針對使用者定製不同格式執行計劃
- 10月份計劃表(每日執行)
- DM7使用Disql執行表空間還原SQL
- 使用聯機SQL執行表空間還原(一)SQL
- DM7使用DMRMAN執行表空間還原
- Mysql SQL最佳化系列之——執行計劃連線方式淺釋MySql
- cluster factor對執行計劃的影響
- MySQL分庫分表的原則MySql
- 執行計劃-3:解釋規則
- 好程式設計師Java學習路線之MySQL的執行計劃程式設計師JavaMySql
- Oceanbase 和 TiDB 粗淺對比之 - 執行計劃TiDB
- ORACLE analyse table方式收集表統計資訊導致SQL執行計劃不準確而效能下降OracleSQL
- 達夢使用聯機SQL執行表空間還原(二)SQL
- 分析執行計劃優化SQLORACLE的執行計劃(轉)優化SQLOracle
- ORACLE expdp在表空間較多的情況下執行非常緩慢Oracle
- 去掉超連結的下劃線
- 【執行計劃】Oracle獲取執行計劃的幾種方法Oracle
- 【Python】單下劃線與雙下劃線的區別Python
- React元件設計之邊界劃分原則React元件
- [轉帖]CentOS 各版本的對應核心表和發行時間表【全】CentOS
- 十六、Mysql之Explain執行計劃MySqlAI
- 獲取執行計劃之Autotrace
- 執行計劃-1:獲取執行計劃
- 按行業劃分的COVID-19疫情對B2B行業的影響【附原資料表】行業
- 線上重定義與普通表改為分割槽表
- 柱狀圖與執行計劃
- 如何將報表與Lazarus中FastReport的資料連線?AST
- DM7使用Disql執行表還原SQL
- DM7使用Disql執行表還原的複雜用法SQL
- 最佳化器-RBO 的規則轉化
- mysql調優之——執行計劃explainMySqlAI
- MongoDb學習之Explain執行計劃MongoDBAI
- 表連線型別型別