Issues with MPP After Using TiFlash

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 关于使用tiflash后mpp的问题

| username: zhanggame1

[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

| username: tidb菜鸟一只 | Original post link

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.

| username: zhanggame1 | Original post link

Okay, I’ll give it a try.

| username: zhanggame1 | Original post link

I didn’t change anything, but after a while, it switched to MPP again. It’s quite strange.

| username: tidb菜鸟一只 | Original post link

If allow=on and enforce=off, it means the optimizer has chosen…

| username: zhanggame1 | Original post link

Currently, the default is allow=on, enforce is off.

| username: Fly-bird | Original post link

The optimizer’s own choice

| username: ShawnYan | Original post link

You can refer to

| username: TiDBer_小阿飞 | Original post link

| username: 人如其名 | Original post link

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.

| username: 像风一样的男子 | Original post link

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.

| username: zhanggame1 | Original post link

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.

| username: heiwandou | Original post link

There is no analyze table after synchronization is completed.

| username: zhanggame1 | Original post link

Makes sense, but shouldn’t this be automatically analyzed?

| username: andone | Original post link

TiDB will automatically analyze the selection.