title | summary | aliases | ||
---|---|---|---|---|
Tune TiFlash Performance |
Learn how to tune the performance of TiFlash. |
|
This document introduces how to tune the performance of TiFlash, including planning machine resources and tuning TiDB parameters.
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.
-
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
:{{< copyable "sql" >}}
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).{{< copyable "sql" >}}
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
.{{< copyable "sql" >}}
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
.{{< copyable "sql" >}}
set @@tidb_opt_distinct_agg_push_down = 1;
-
If the
JOIN
operator does not choose the MPP mode, you can modify the value oftidb_opt_network_factor
to make theJOIN
operator choose the MPP mode:The variable
tidb_opt_network_factor
is used to set the ratio of network overhead that the optimizer takes into account when calculating the cost. The smaller the variable value is, the smaller the estimated cost for a large amount of network transmissions is, and the more TiDB inclined to choose the MPP operator.{{< copyable "sql" >}}
set @@tidb_opt_network_factor = 0.001;