Issues with inaccurate TiDB execution plans: TiFlash is not used, forcing TiFlash results in much faster performance

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

Original topic: tidb执行计划不准问题,有tiflash不走,强制走tiflash快很多

| username: wenyi

A SQL statement, with the latest collected statistics, normally doesn’t use TiFlash but uses TiKV, resulting in much worse performance. It seems that TiDB’s execution plan selection still has issues.
Execution plan as follows:



Execution plan as follows:

| username: Running | Original post link

I’ve encountered a similar issue. My current solution is to provide independent TiDB server nodes for large-scale queries and set the engine to the TiFlash standalone engine.

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

Why does your SQL have to use TiFlash? I don’t see any aggregate functions…

| username: WalterWj | Original post link

Collect the statistics and take a look.

| username: wenyi | Original post link

Statistics have been collected.

| username: WalterWj | Original post link

In that case, the CBO probably doesn’t think it should be used. If it doesn’t work, you can manually intervene with a hint.

| username: yulei7633 | Original post link

Add a hint to manually specify.

| username: wenyi | Original post link

Set the engine to the standalone TiFlash engine, and the query reports an error.

| username: Jiawei | Original post link

Looking at the execution plan, the estimated number of rows scanned by TiKV is significantly less than that of TiFlash. It doesn’t seem right. Could it be that the index is not effective or something like that?

| username: wenyi | Original post link

There is no such thing as indexes in TiFlash, right?
Columnar databases don’t seem to require creating indexes like row-based databases do.

| username: yilong | Original post link

Can I use plan replayer to provide feedback?

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.