Sign InTry Free

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:

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.

Download PDFRequest docs changesEdit this page
Was this page helpful?
Open Source Ecosystem
Chaos Mesh
© 2022 PingCAP. All Rights Reserved.