-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Last bulk of special week changes (#3392)
* Last bulk of special week changes * Create credits.md * put information-scheme.md into folder * add sql tuning files * to align pingcap/docs-cn#3141 * fix 2 links * Update control-execution-plan.md * add SQL Logical Optimization * rename according to docs-cn * Create sql-physical-optimization.md * Update sql-optimization-concepts.md * update toc * Apply suggestions from code review Co-authored-by: Lilian Lee <lilin@pingcap.com> Co-authored-by: Lilian Lee <lilin@pingcap.com> Co-authored-by: ti-srebot <66930949+ti-srebot@users.noreply.github.com>
- Loading branch information
1 parent
dcba055
commit 612b1d2
Showing
12 changed files
with
251 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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,11 @@ | ||
--- | ||
title: Control Execution Plan | ||
--- | ||
|
||
# Control Execution Plan | ||
|
||
The first two chapters of SQL Tuning introduce how to understand TiDB's execution plan and how TiDB generates an execution plan. This chapter introduces what methods can be used to control the generation of the execution plan when you determine the problems with the execution plan. This chapter mainly includes the following three aspects: | ||
|
||
- In [Optimizer Hints](/optimizer-hints.md), you will learn how to use hints to guide TiDB to generate an execution plan. | ||
- But hints change the SQL statement intrusively. In some scenarios, hints cannot be simply inserted. In [SQL Plan Management](/sql-plan-management.md), you will know how TiDB uses another syntax to non-intrusively control the generation of execution plans, and the methods of automatic execution plan evolution in the background to alleviate the execution plan instability caused by reasons such as version upgrades, which degrades cluster performance. | ||
- Finally, you will learn how to use the blocklist in [Blocklist of Optimization Rules and Expression Pushdown](/blocklist-control-plan.md). |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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,18 @@ | ||
--- | ||
title: SQL Logical Optimization | ||
--- | ||
|
||
# SQL Logical Optimization | ||
|
||
This chapter explains some key logic rewrites to help you understand how TiDB generates the final query plan. For example, when you execute the `select * from t where t.a in (select * from t1 where t1.b=t.b)` query in TiDB, you will find that the `IN` sub-query `t.a in (select t1.a from t1 where t1.b=t.b` does not exist because TiDB has made some rewrites here. | ||
|
||
This chapter introduces the following key rewrites: | ||
|
||
- [Subquery Related Optimizations](/subquery-optimization.md) | ||
- [Column Pruning](/column-pruning.md) | ||
- [Decorrelation of Correlated Subquery](/correlated-subquery-optimization.md) | ||
- [Eliminate Max/Min](/max-min-eliminate.md) | ||
- [Predicates Push Down](/predicate-push-down.md) | ||
- [Partition Pruning](/partition-pruning.md) | ||
- [TopN and Limit Operator Push Down](/topn-limit-push-down.md) | ||
- [Join Reorder](/join-reorder.md) |
This file contains 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 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,14 @@ | ||
--- | ||
title: SQL Physical Optimization | ||
--- | ||
|
||
# SQL Physical Optimization | ||
|
||
Physical optimization is cost-based optimization, which makes a physical execution plan for the logical execution plan generated in the previous stage. In this stage, the optimizer selects a specific physical implementation for each operator in the logical execution plan. Different physical implementations of logical operators have different time complexity, resource consumption and physical properties. In this process, the optimizer determines the cost of different physical implementations based on the statistics of the data, and selects the physical execution plan with the smallest overall cost. | ||
|
||
[Understand the Query Execution Plan](/query-execution-plan.md) has introduced some physical operators. This chapter focuses on the following aspects: | ||
|
||
- In [Index Selection](/choose-index.md), you will learn how to select the optimal index to access tables when TiDB has multiple indexes on a table. | ||
- In [Introduction to Statistics](/statistics.md), you will learn what statistics TiDB collects to obtain the data distribution of a table. | ||
- [Wrong Index Solution](/wrong-index-solution.md) introduces how to use the right index when you find the index is selected wrongly. | ||
- [Distinct Optimization](/agg-distinct-optimization.md) introduces an optimization related to the `DISTINCT` keyword during physical optimization. In this section, you will learn its advantages and disadvantages and how to use it. |
This file contains 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 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 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,11 @@ | ||
--- | ||
title: SQL Tuning Overview | ||
--- | ||
|
||
# SQL Tuning Overview | ||
|
||
The previous "Troubleshoot" chapter describes some ways to locate some queries that affect the cluster, and that if some queries' execution time does not meet expectations, you need to analyze the execution result to find the cause. In this chapter, the following sections introduce how to tune a specific query: | ||
|
||
- In the first section, [Understand the Query Execution Plan](/query-execution-plan.md) introduces how to use the `EXPLAIN` and `EXPLAIN ANALYZE` statements to understand how TiDB executes a query. | ||
- In the second section, [SQL Optimization Process](/sql-optimization-concepts.md) introduces the optimizations used internally by TiDB, which involves some equivalent SQL conversions and the selection of physical plans. This section helps you understand how TiDB generates the final execution plan. | ||
- In the third section, [Control Execution Plan](/control-execution-plan.md) introduces the ways to control the generation of the execution plan, which improves the execution speed of the query and reduces its impact on the overall performance of the cluster or online business. |
This file contains 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