-
Notifications
You must be signed in to change notification settings - Fork 1.2k
perf-tuning:adjust the structure of the SQL tuning section
#3149
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a5c3a58
性能调优:调整 SQL 性能调优的结构
winoros 4b47f4e
Merge branch 'docs-special-week' into sql-tunning-tree
winoros 56ad0ad
remove hard tab and fix ci
winoros 00634c7
address comments
winoros 7b38309
Merge branch 'docs-special-week' into sql-tunning-tree
winoros 11cbde2
Merge branch 'docs-special-week' into sql-tunning-tree
yikeke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: Distinct 优化 | ||
| category: performance | ||
| --- | ||
|
|
||
| # Distinct 优化 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 优化规则及表达式下推的黑名单 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 优化规则及表达式下推的黑名单 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 列裁剪 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 列裁剪 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 关联子查询去关联 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 关联子查询去关联 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 索引的选择 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 索引的选择 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 分区裁剪 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 分区裁剪 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 谓词下推 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 谓词下推 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
|
||
| <!-- | ||
|
Member
Author
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) | ||
| --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 统计信息介绍 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 统计信息介绍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 子查询相关的优化 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 子查询相关的优化 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: TopN 和 Limit 下推 | ||
| category: performance | ||
| --- | ||
|
|
||
| # TopN 和 Limit 下推 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| title: 错误索引的解决方案 | ||
| category: performance | ||
| --- | ||
|
|
||
| # 错误索引的解决方案 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
我们目前有下面这些 optimize rule:
这里像 外连接消除、投影消除等 都是没有提到的,我们要考虑在文档加入这些吗?
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.
人手不一定够?不如我们先写完现有这一批,后面再加一批
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.
🉑️