When a query arrives, how does TiDB determine whether to execute it using column storage or row storage?

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

Original topic: 查询到来时,TiDB如何判断该查询交给列存执行还是交给行存

| username: Vector_shine

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version] v7.0.0
[Reproduction Path] Operations performed that led to the issue
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]

| username: 啦啦啦啦啦 | Original post link

If it is in intelligent selection mode, the optimizer will make a choice based on cost estimation.

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

If the engine has both TiKV and TiFlash, the CBO (Cost-Based Optimizer) will decide based on cost whether the executor should use TiKV or TiFlash.

| username: TiDBer_pkQ5q1l0 | Original post link

Check whether the execution plan uses TiKV or TiFlash.

| username: Running | Original post link

Use the desc/explain SQL statement to see which engine is being used. Additionally, it seems that the Cost-Based Optimizer (CBO) can sometimes be a bit lazy. The best approach is to set up two TiDB server nodes to meet different scenario requirements.