Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 为什么这条简单的SQL会被认为是笛卡尔乘积?
[TiDB Usage Environment] Test
[TiDB Version] v6.1.1
[Encountered Problem]
Why is a simple query statement considered a Cartesian product?
select min(k), max(k) from mytable;
Error: ERROR 8110 (HY000): Cartesian product is unsupported
[Reproduction Path]
[Problem Phenomenon and Impact]
Please provide the table structure and the explain result.
The table structure is attached in the image, and the explain command doesn’t work. It should be a restriction set by the DBA.
Found another bug~ Congratulations
Huh? It’s only my first day using TiDB today. And there’s already a bug?
SHOW CREATE TABLE statement
The image is not visible. Please provide the text you need translated.
Modify the related configuration parameters of TiDB:
Note that the following operation requires restarting the TiDB instance!!!
Remove the performance.cross-join: false in the picture
Then run tiup cluster reload -R tidb
Then check the execution plan of the table again?
The image you provided is not visible. Please provide the text you need translated.
The optimizer in the logical optimization phase converts the process of obtaining max() and min() through an index into two topN operations followed by a cross join. After logical optimization, it checks whether the SQL after logical optimization contains a cross join and whether performance.cross-join=false is set. If so, it will report the error you just mentioned. I think this can be understood as a bug in the optimizer, after all, the cross join is generated by the optimizer’s own logical optimization, not by user behavior. A temporary workaround is to remove the performance.cross-join=false configuration parameter. Go ahead and file an issue.
Bro, on your first day, you were already modifying parameters and restarting the data. That’s impressive! On my first day, I couldn’t even understand the concept of HTAP…
Congratulations on finding the bug.
Learned about another pitfall.
Congratulations on finding the bug.