diff --git a/TOC.md b/TOC.md index a2ec8b6db4689..93bd9c5d3a46d 100644 --- a/TOC.md +++ b/TOC.md @@ -294,6 +294,7 @@ - [Statement Summary Table](/statement-summary-tables.md) - [Tune TiKV](/tune-tikv-performance.md) - [Operating System Tuning](/tune-operating-system.md) + - [Column Pruning](/column-pruning.md) + Key Monitoring Metrics - [Overview](/grafana-overview-dashboard.md) - [TiDB](/grafana-tidb-dashboard.md) diff --git a/column-pruning.md b/column-pruning.md new file mode 100644 index 0000000000000..d018ab15084a6 --- /dev/null +++ b/column-pruning.md @@ -0,0 +1,20 @@ +--- +title: Column Pruning +summary: Learn about the usage of column pruning in TiDB. +--- + +# Column Pruning + +The basic idea of column pruning is that for columns not used in the operator, the optimizer does not need to retain them during optimization. Removing these columns reduces the use of I/O resources and facilitates the subsequent optimization. The following is an example of column repetition: + +Suppose there are four columns (a, b, c, and d) in table t. You can execute the following statement: + +{{< copyable "sql" >}} + +```sql +select a from t where b> 5 +``` + +In this query, only column a and column b are used, and column c and column d are redundant. Regarding the query plan of this statement, the `Selection` operator uses column b. Then the `DataSource` operator uses columns a and column b. Columns c and column d can be pruned because the `DataSource` operator does not read them. + +Therefore, when TiDB performs a top-down scanning during the logic optimization phase, redundant columns are pruned to reduce waste of resources. This scanning process is called "Column Pruning", corresponding to the `columnPruner` rule. If you want to disable this rule, refer to [The Blocklist of Optimization Rules and Expression Pushdown](/blocklist-control-plan.md).