Tune TiFlash Performance
This document introduces how to tune the performance of TiFlash, including planning machine resources and tuning TiDB parameters.
Plan resources
If you want to save machine resources and have no requirement on isolation, you can use the method that combines the deployment of both TiKV and TiFlash. It is recommended that you save enough resources for TiKV and TiFlash respectively, and do not share disks.
Tune TiDB parameters
For the TiDB node dedicated to OLAP/TiFlash, it is recommended that you increase the value of the
tidb_distsql_scan_concurrency
configuration item for this node to80
:set @@tidb_distsql_scan_concurrency = 80;Enable the super batch feature:
You can use the
tidb_allow_batch_cop
variable to set whether to merge Region requests when reading from TiFlash.When the number of Regions involved in the query is relatively large, try to set this variable to
1
(effective for coprocessor requests withaggregation
operators that are pushed down to TiFlash), or set this variable to2
(effective for all coprocessor requests that are pushed down to TiFlash).set @@tidb_allow_batch_cop = 1;Enable the optimization of pushing down aggregate functions before TiDB operators such as
JOIN
orUNION
:You can use the
tidb_opt_agg_push_down
variable to control the optimizer to execute this optimization. When the aggregate operations are quite slow in the query, try to set this variable to1
.set @@tidb_opt_agg_push_down = 1;Enable the optimization of pushing down aggregate functions with
Distinct
before TiDB operators such asJOIN
orUNION
:You can use the
tidb_opt_distinct_agg_push_down
variable to control the optimizer to execute this optimization. When the aggregate operations withDistinct
are quite slow in the query, try to set this variable to1
.set @@tidb_opt_distinct_agg_push_down = 1;