# Expression Push Down
__*TiKV expression push down down*__
+ Push down expressions to **TiKV**
  + When TiDB reads data from TiKV, TiDB can push down some expressions to TiKV as much as possible, thus reducing the amount of data transfer and the computational workload of a single TiDB node
  + Logical operations: **`AND (&&)`** , **`OR (||)`** ,  **`NOT (!)`** 
  + Comparisons: **`<`** , **`<=`** ,  **`=`** , **`!= (<>)`** ,  **`>`** , **`>=`** ,  **`<=>`** , **`IN()`** ,  **`IS NULL`** , **`LIKE`** ,  **`IS TRUE`** , **`IS FALSE`** ,  **`COALESCE()`** 
  + arithmetic operations: **`+`** , **`-`** ,  **`*`** , **`/`** ,  **`ABS()`** , **`CEIL()`** ,  **`CEILING()`** , **`FLOOR()`** 
  + Control flow operations: **`CASE`** , **`IF()`** ,  **`IFNULL()`** 
  + Date arithmetic: **`DATE_FORMAT()`** 
+ Determine if the operation supports expression down-pushing by observing**task.cop [tikv]** of the task column in the execution plan

```
tidb> EXPLAIN SELECT name, mass FROM universe.planets WHERE name RLIKE 'M.*';
+-------------------------+---------+-----------+---------------+--------------------------------------+
| id                      | estRows | task      | access object | operator info                        |
+-------------------------+---------+-----------+---------------+--------------------------------------+
| Selection_5             | 8.00    | ~!@root      |               | regexp(universe.planets.name, "M.*")@!~ |
| └─TableReader_7         | 10.00   | root      |               | data:TableFullScan_6                 |
|   └─TableFullScan_6     | 10.00   | cop[tikv] | table:planets | keep order:false, stats:pseudo       |
+-------------------------+---------+-----------+---------------+--------------------------------------+
```

------------------------------------------------------------
For example, observe the differences between the following two implementation plans:

```
tidb> EXPLAIN SELECT name, mass FROM universe.planets WHERE name RLIKE 'M.*';
+-------------------------+---------+-----------+---------------+--------------------------------------+
| id                      | estRows | task      | access object | operator info                        |
+-------------------------+---------+-----------+---------------+--------------------------------------+
| Selection_5             | 8.00    | root      |               | regexp(universe.planets.name, "M.*") |
| └─TableReader_7         | 10.00   | root      |               | data:TableFullScan_6                 |
|   └─TableFullScan_6     | 10.00   | cop[tikv] | table:planets | keep order:false, stats:pseudo       |
+-------------------------+---------+-----------+---------------+--------------------------------------+
3 rows in set, 1 warning (0.00 sec)

tidb> EXPLAIN SELECT name, mass FROM universe.planets WHERE name LIKE 'M%';
+-------------------------------+---------+-----------+---------------------------------+-------------------------------------------------+
| id                            | estRows | task      | access object                   | operator info                                   |
+-------------------------------+---------+-----------+---------------------------------+-------------------------------------------------+
| IndexLookUp_10                | 0.25    | root      |                                 |                                                 |
| ├─IndexRangeScan_8(Build)     | 0.25    | cop[tikv] | table:planets, index:name(name) | range:["M","N"), keep order:false, stats:pseudo |
| └─TableRowIDScan_9(Probe)     | 0.25    | cop[tikv] | table:planets                   | keep order:false, stats:pseudo                  |
+-------------------------------+---------+-----------+---------------------------------+-------------------------------------------------+
3 rows in set (0.00 sec)
```
