Today I encountered another strange issue: after performing analyze on a large table and running for a few days, I found that the execution plan of the same SQL in the dashboard statistics is different from the execution plan in the command line

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

Original topic: 今天又遇到一个奇怪的问题:对大表进行analyze收集后,运行了几天,发现在dashboard统计到的同样的SQL的执行计划和命令行的执行计划不一样

| username: vcdog

[TiDB Usage Environment] Production Environment
[TiDB Version] v6.5.0
[Reproduction Path] Encountered another strange issue today: after collecting analyze on a large table, running for a few days, I found that the execution plan of the same SQL in the dashboard statistics is different from the execution plan in the command line.
[Encountered Problem: Phenomenon and Impact] Encountered another strange issue today: after collecting analyze on a large table, running for a few days, I found that the execution plan of the same SQL in the dashboard statistics is different from the execution plan in the command line.
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

  1. This is the execution plan captured from the TiDB dashboard:

  2. This is the execution plan captured from the command line:

| username: 有猫万事足 | Original post link

The issue lies with the dashboard display.

I encountered this problem with version 7.1 as well. I think it would be good to report a bug for the dashboard.

These two execution plans are actually the same. Currently, only MPP has ExchangeSender, which is needed to send/receive data from other TiFlash nodes. So, having this operator basically confirms it’s MPP. In other words, the display of cop[tiflash] in the task column of the dashboard is not normal.

| username: DBAER | Original post link

I feel that the person above is right.

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

Indeed, the appearance of this already confirms it is MPP.

| username: vcdog | Original post link

Okay, I’ll go ahead and raise it. Where should I raise it, on GitHub issues or somewhere else?

| username: 源de爸 | Original post link

Indeed, it’s a bit strange.

| username: 芝士改变命运 | Original post link

Refer to the first post.

| username: h5n1 | Original post link

It should be the issue mentioned in the first post. The display logic and source of explain and dashboard are different. The dashboard parses the plan using tidb_decode_plan, and only useful information is retained when storing the plan to minimize its size. Some strings are concatenated during the final parsing. I encountered a similar issue before where the logic for concatenating other strings was not updated, leading to inconsistencies in the displayed execution plan. I can’t find that post at the moment.

Reference:

| username: vcdog | Original post link

So, can this issue be considered a bug? Haha.

| username: TiDBer_嘎嘣脆 | Original post link

It should be a bug.

| username: h5n1 | Original post link

You can refer to this. The execution plan that actually uses the cop request method does not have an operator similar to ExchangeSender.

| username: TIDB-Learner | Original post link

I’ve encountered a similar situation.

| username: 有猫万事足 | Original post link

Forums are also fine, and you can earn points.

【Suggestions & Feedback · Product Defects】

| username: xiaoqiao | Original post link

Go back and test this bug.

| username: shunzi | Original post link

Forum topic is fine.

| username: Soysauce520 | Original post link

The actual analyze execution shall prevail, addressing the issue with the execution plan version. It seems to have improved after upgrading to 6.5.6.

| username: time-and-fate | Original post link

I also replied in the GitHub issue.
As mentioned above, the issue with cop is a display problem. In reality, if there is an ExchangeSender operator, it is definitely mpp and not cop.
Tidb started supporting another format of execution plan output in previous versions. Starting from v7.4, the dashboard began using this new format of execution plan for display, which does not have this display issue and is almost identical to the format of EXPLAIN ANALYZE, with just an additional column for estimated cost.
Before v7.4, you could also look at the plan in the “Graph” panel, which also does not have this display issue. Alternatively, you can query the BINARY_PLAN column from the corresponding system table and use tidb_decode_binary_plan() to parse it, which is also consistent with the EXPLAIN ANALYZE format.