Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 关于使用tiflash后mpp的问题
[Test Environment for TiDB]
[TiDB Version] 7.1
[Reproduction Path] What operations were performed to encounter the issue
[Encountered Issue: Problem Phenomenon and Impact]
Testing TiFlash’s MPP
Added 2 TiFlash components, then used the command:
ALTER TABLE z_dev.clerk_daily_report SET TIFLASH REPLICA 2;
to add 2 replicas.
This table has approximately 60 million rows of data.
The problem is that MPP is rarely seen in the execution plan. Under what circumstances will MPP be used?
Table structure
The execution plan is as follows, summing up one column
You can change the selection strategy by modifying the values of the variables tidb_allow_mpp
and tidb_enforce_mpp
. If it is for testing, you can enable both options, so that all SQL will use MPP.
Okay, I’ll give it a try.
I didn’t change anything, but after a while, it switched to MPP again. It’s quite strange.
If allow=on and enforce=off, it means the optimizer has chosen…
Currently, the default is allow=on, enforce is off.
The optimizer’s own choice
In scenarios involving full table scans of large tables, TiFlash is generally used. The reason it might not have been used initially could be that the database hasn’t fully synchronized with TiFlash yet. You need to check the TiFlash data synchronization status (information_schema.tiflash_replica). Once everything is fully synchronized, TiFlash will be used consistently.
By default, TiDB’s optimizer automatically decides whether to use MPP mode. You can change the selection strategy by modifying the values of the variables tidb_allow_mpp
and tidb_enforce_mpp
.
After a day of checking following the synchronization, there was no progress. I suspect it has something to do with the execution plan cache. Finally, restarting the TiDB server resolved the issue.
There is no analyze table after synchronization is completed.
Makes sense, but shouldn’t this be automatically analyzed?
TiDB will automatically analyze the selection.