# TiFlash's Main Feature: Engine Smart Selection

![`smart`](TiFlashSmartSelection_aa_004_20220513.png)

-------------------------------------------------------------
TiDB server, as a coordinator, can evaluate query statements and automatically decide to execute the query on TiKV or TiFlash or both, as shown in the figure.

Since `product` table does not take any columns, only filters the condition `product.batch_id = 'B1328'`, and there is an index of `(pid,batch_id)` in the `product` table, it is possible to choose to do index read in TiKV, filtering out the data in the `product` table that meets the condition.

Taking the column of `price` from `sales` to do aggregation (AVG) without any filter condition is equivalent to a full table scan, so it is more suitable to do table scan in TiFlash.

Finally, aggregate the two data paths that meet the conditions on the TiDB server to get the result.
