Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 分区列排序异常
【TiDB Usage Environment】Production Environment
【TiDB Version】v7.1.0
【Reproduction Path】Partition Column Sorting
【Encountered Issue: Issue Phenomenon and Impact】internal error: unionexec chunk column count mismatch, reg: 43, result: 44
【Resource Configuration】
【Attachments: Screenshots/Logs/Monitoring】
Is the partition column referring to the partition field of the partition table? Are there issues with sorting other fields?
I tested it, and the same error occurs with the field in the WHERE clause, but other fields are normal.
I found an issue in version 5.2, but your version is already 7.1. This bug shouldn’t still exist, right?
Internal error when pushdown agg into partitionUnion · Issue #29705 · pingcap/tidb (github.com)
Upgraded from v6.5.0, not sure if it has been reintroduced… It was normal before.
Upgrading to version 7.1.1 still has this issue.
I found that it can be executed without adding limit, but there will still be an error if limit is added… Does anyone else have this problem?
Are the number of columns returned by the involved SELECT statements consistent?
There are some inconsistencies, but it is possible within the same partition. There will be issues across partitions.
How is the partition key defined?
Try adding jialimit
to see if the execution plan is the same.
PARTITION BY RANGE (DateCode
)
Please post the execution plan.
It is highly likely that the static partition prune mode is being used. Can you try executing it in dynamic mode? Dynamic Pruning Mode
The image is not visible. Please provide the text you need translated.
Will changing to dynamic mode have any impact on the database?
The default for version 7.1 is dynamic mode.
I am also puzzled, but after checking the documentation, I guess the statistics are not fully collected.
So it’s still in static mode.
There won’t be any impact. In higher versions, dynamic mode is already used by default. After switching to dynamic mode, you need to analyze the table to collect statistics, otherwise, it will still use static mode.
Then do I still need to try dynamic?