# Column pruning

+ `SELECT name FROM emp WHERE id < 3;` 


![left](./student-guide/diagram/16-Column-clipping-01-01.png)

------------------------------------------------------------
Logic optimization - column pruning
What is column pruning: Suppose we have three columns ID, Name, and Address in our table. When our query only involves the name and id columns, the selection operator read the name column, and the datasource uses the id column, and the address column can be clipped.
In the optimization method of column pruning, the optimizer traverses from top to bottom according to the logical order of the logical execution plan abstract syntax tree (AST), the columns required by the current node are output, and the columns required by the parent node are accumulated and fed back to the child nodes, adding up all the columns that need to be counted, and finally return the required columns to the root node.

The operators affected by column pruning are:
- Projection mapping operation clips non-output columns
- DataSource data source pruning unused columns
- Columns used by Aggregation confirmation
