-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf-tuning:adjust the structure of the SQL tuning
section
#3149
Changes from 3 commits
a5c3a58
4b47f4e
56ad0ad
00634c7
7b38309
11cbde2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,16 +116,27 @@ | |
+ [软件版本](/tune-software-version.md) @张文博 | ||
+ 配置 | ||
+ [TiKV 调优](/tune-tikv-performance.md) @刘玮 | ||
+ SQL 性能调优 | ||
+ [调优基本概念](/sql-optimization-concepts.md) @崔一丁 | ||
+ 优化器概览 | ||
+ [执行计划](/query-execution-plan.md) @崔一丁 | ||
+ [分布式执行计划](/distributed-exectuion-plan.md) @崔一丁 | ||
+ 管理执行计划 | ||
+ [执行计划绑定](/execution-plan-binding.md) @崔一丁 | ||
+ [Optimizer Hints](/optimizer-hints.md) @崔一丁 | ||
+ [使用 Index Merge 方式访问表](/index-merge.md) @崔一丁 | ||
+ [Join Reorder 算法简介](/join-reorder.md) @崔一丁 | ||
+ [SQL 性能调优](/sql-tuning-overview.md) @崔一丁 | ||
+ [理解 TiDB 执行计划](/query-execution-plan.md) | ||
+ [SQL 优化流程简介](/sql-optimization-concepts.md) | ||
+ [逻辑优化](/sql-logical-optimization.md) | ||
+ [子查询相关的优化](/subquery-optimization.md) | ||
+ [列裁剪](/column-pruning.md) | ||
+ [关联子查询去关联](/correlated-subquery-optimization.md) | ||
+ [Max/Min 消除](/max-min-eliminate.md) | ||
+ [谓词下推](/predicate-push-down.md) | ||
+ [分区裁剪](/partition-pruning.md) | ||
+ [TopN 和 Limit 下推](/topn-limit-push-down.md) | ||
+ [Join Reorder](/join-reorder.md) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我们目前有下面这些 optimize rule: var optRuleList = []logicalOptRule{
&gcSubstituter{},
&columnPruner{},
&buildKeySolver{},
&decorrelateSolver{},
&aggregationEliminator{},
&projectionEliminator{},
&maxMinEliminator{},
&ppdSolver{},
&outerJoinEliminator{},
&partitionProcessor{},
&aggregationPushDownSolver{},
&pushDownTopNOptimizer{},
&joinReOrderSolver{},
&columnPruner{}, // column pruning again at last, note it will mess up the results of buildKeySolver
} 这里像 外连接消除、投影消除等 都是没有提到的,我们要考虑在文档加入这些吗? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 人手不一定够?不如我们先写完现有这一批,后面再加一批 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🉑️ |
||
+ [物理优化](/sql-physical-optimization.md) | ||
+ [索引的选择](/index-choose.md) | ||
+ [统计信息介绍](/statistics-intro.md) | ||
+ [发现索引选错时](/wrong-index-solution.md) | ||
+ [Distinct 优化](/agg-distinct-optimization.md) | ||
+ [控制执行计划](/control-execution-plan.md) | ||
+ [Optimizer Hints](/optimizer-hints.md) | ||
+ [执行计划绑定](/execution-plan-binding.md) | ||
+ [优化规则及表达式下推的黑名单](/blacklist-control-plan.md) | ||
+ [性能监控](/monitor-sql-performance.md) @崔一丁 | ||
+ 教程 | ||
+ 参考指南 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: Distinct 优化 | ||
category: performance | ||
--- | ||
|
||
# Distinct 优化 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 优化规则及表达式下推的黑名单 | ||
category: performance | ||
--- | ||
|
||
# 优化规则及表达式下推的黑名单 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 列裁剪 | ||
category: performance | ||
--- | ||
|
||
# 列裁剪 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: 控制执行计划 | ||
category: performance | ||
--- | ||
|
||
# 控制执行计划 | ||
|
||
Sub topics: | ||
|
||
- [Optimizer Hints](/optimizer-hints.md) | ||
- [执行计划绑定](/execution-plan-binding.md) | ||
- [优化规则及表达式下推的黑名单](/blacklist-control-plan.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 关联子查询去关联 | ||
category: performance | ||
--- | ||
|
||
# 关联子查询去关联 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 索引的选择 | ||
category: performance | ||
--- | ||
|
||
# 索引的选择 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 分区裁剪 | ||
category: performance | ||
--- | ||
|
||
# 分区裁剪 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 谓词下推 | ||
category: performance | ||
--- | ||
|
||
# 谓词下推 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: 逻辑优化 | ||
category: performance | ||
--- | ||
|
||
# 逻辑优化 | ||
|
||
sub topics: | ||
|
||
- [子查询相关的优化](/subquery-optimization.md) | ||
- [列裁剪](/column-pruning.md) | ||
- [关联子查询去关联](/correlated-subquery-optimization.md) | ||
- [Max/Min 消除](/max-min-eliminate.md) | ||
- [谓词下推](/predicate-push-down.md) | ||
- [分区裁剪](/partition-pruning.md) | ||
- [TopN 和 Limit 下推](/topn-limit-push-down.md) | ||
- [Join Reorder](/join-reorder.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
--- | ||
title: SQL 优化流程简介 | ||
category: reference | ||
category: performance | ||
aliases: ['/docs-cn/dev/reference/performance/sql-optimizer-overview/'] | ||
--- | ||
|
||
# SQL 优化流程简介 | ||
|
||
sub topics: | ||
|
||
- [逻辑优化](/sql-logical-optimization.md) | ||
- [物理优化](/sql-physical-optimization.md) | ||
|
||
<!-- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commented content will move to |
||
在 TiDB 中,SQL 优化过程分为逻辑优化和物理优化两个阶段。 | ||
|
||
## 逻辑优化简介 | ||
|
||
逻辑优化是基于规则的优化,对输入的逻辑执行计划按顺序应用一些优化规则,从而使整个逻辑执行计划变得更好。这些优化规则包括: | ||
|
||
- 列裁剪 | ||
- 投影消除 | ||
- 关联子查询去关联 | ||
- [子查询相关的优化](./subquery-optimization.md) | ||
- [列裁剪](./column-pruning.md) | ||
- [关联子查询去关联](./correlated-subquery-optimization.md) | ||
- [Max/Min 消除](/max-min-eliminate.md) | ||
- 谓词下推 | ||
- 分区裁剪 | ||
- TopN 和 Limit 下推 | ||
- [谓词下推](./predicate-push-down.md) | ||
- [分区裁剪](./partition-pruning.md) | ||
- [TopN 和 Limit 下推](./topn-limit-push-down.md) | ||
- [Join Reorder](/join-reorder.md) | ||
|
||
## 物理优化简介 | ||
|
||
物理优化是基于代价的优化,为上一阶段产生的逻辑执行计划制定物理执行计划。这一阶段中,优化器会为逻辑执行计划中的每个算子选择具体的物理实现。逻辑算子的不同物理实现有着不同的时间复杂度、资源消耗和物理属性等。在这个过程中,优化器会根据数据的统计信息来确定不同物理实现的代价,并选择整体代价最小的物理执行计划。 | ||
|
||
逻辑执行计划是一个树形结构,每个节点对应 SQL 中的一个逻辑算子。同样的,物理执行计划也是一个树形结构,每个节点对应 SQL 中的一个物理算子。逻辑算子只描述这个算子的功能,而物理算子则描述了完成这个功能的具体算法。对于同一个逻辑算子,可能有多个物理算子实现,比如 `LogicalAggregate`,它的实现可以是采用哈希算法的 `HashAggregate`,也可以是流式的 `StreamAggregate`。不同的物理算子具有不同的物理属性,也对其子节点有着不同的物理属性的要求。物理属性包括数据的顺序和分布等。TiDB 中现在只考虑了数据的顺序。 | ||
|
||
sub topics: | ||
|
||
- [索引的选择](./index-choose.md) | ||
- [统计信息介绍](./statistics-intro.md) | ||
- [发现索引选错时](./wrong-index-solution.md) | ||
- [Distinct 优化](./agg-distinct-optimization.md) | ||
--> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 物理优化 | ||
category: performance | ||
--- | ||
|
||
# 物理优化 | ||
|
||
sub topics: | ||
|
||
- [索引的选择](/index-choose.md) | ||
- [统计信息介绍](/statistics-intro.md) | ||
- [发现索引选错时](/wrong-index-solution.md) | ||
- [Distinct 优化](/agg-distinct-optimization.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: SQL 性能调优 | ||
category: performance | ||
--- | ||
|
||
# SQL 调优概览 | ||
|
||
Sub Topics: | ||
|
||
- [理解 TiDB 执行计划](/query-execution-plan.md) | ||
- [SQL 优化流程简介](/sql-optimization-concepts.md) | ||
- [控制执行计划](/control-execution-plan.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 统计信息介绍 | ||
category: performance | ||
--- | ||
|
||
# 统计信息介绍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 子查询相关的优化 | ||
category: performance | ||
--- | ||
|
||
# 子查询相关的优化 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: TopN 和 Limit 下推 | ||
category: performance | ||
--- | ||
|
||
# TopN 和 Limit 下推 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: 发现索引选错时 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个文档标题改一下吧,比如叫《选择正确的索引》,多处存在 |
||
category: performance | ||
--- | ||
|
||
# 发现索引选错时 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
咱们当前官网文档不支持点击这个标题,即包含子项的标题。 @YiniXu9506 确认下?新版文档实现里会支持类似的吗,不论在 TOC 的层级是第几级?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哦哦 那我小改一下