Bug #116875 | condition of 'ReuseRangeEstimateForRef-4' is wrong and cannot correct the fanout estimation for a REF of join | ||
---|---|---|---|
Submitted: | 4 Dec 2024 16:25 | Modified: | 5 Dec 2024 11:31 |
Reporter: | NANLONG YU | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Optimizer, Optimizer bug |
[4 Dec 2024 16:25]
NANLONG YU
[4 Dec 2024 16:27]
NANLONG YU
there is create info and data of table t2 in t2.sql
Attachment: t2.sql (application/octet-stream, text), 1.71 KiB.
[4 Dec 2024 16:28]
NANLONG YU
there is create info and data of t1 in t1.sql
Attachment: t1.sql (application/octet-stream, text), 6.66 KiB.
[4 Dec 2024 17:00]
MySQL Verification Team
Hi Mr. YU, Thank you for your bug report. However, we can not repeat it. In order to repeat it, we need rows for the table(s). When you send us table contents, we shall try to repeat it. Thanks in advance.
[5 Dec 2024 10:50]
MySQL Verification Team
Hi Mr. YU, Thank you for your bug report. This is now a verified Optimiser feature request covering all versions from 8.0 to 9.1. It is a feature request because the change that you recommended would work for this type of query, but not for some other query types. Verified.
[5 Dec 2024 11:15]
NANLONG YU
Hi Thank u for verifying this. Based on the comments in the code of 'ReuseRangeEstimateForRef-4', I think the original intention of the person who wrote this code is as I have described. The code of 'ReuseRangeEstimateForRef-2' serves a similar function and can be referenced for comparison. To clarify, the code of 'ReuseRangeEstimateForRef-4' performs a fix when not all columns in the index are covered, while the code of 'ReuseRangeEstimateForRef-2' performs a fix when all columns in the index are covered. In summary, I believe that it was a subtle mistake made by the person writing the code, rather than any other intention.
[5 Dec 2024 11:31]
NANLONG YU
Hi, Thanks again for verifying this bug. Based on the comments in the code of 'ReuseRangeEstimateForRef-4', I think the original intention of the person who wrote this code is as I have described. The code of 'ReuseRangeEstimateForRef-2' serves a similar function and can be referenced for comparison. To clarify, the code of 'ReuseRangeEstimateForRef-4' performs a fix when not all columns in the index are covered, while the code of 'ReuseRangeEstimateForRef-2' performs a fix when all columns in the index are covered. In summary, I believe that it was a subtle mistake made by the person writing the code, rather than any other intention. Let me clarify further: for this if-condition, `table->quick_key_parts[key]` represents the number of prefix columns of the index used by the ref access. The value of `(1 << table->quick_key_parts[key])` with a bit of 1 actually indicates the position of a column in the index that is not used by the ref access. Since this column is not being used at all, why should we use the cardinality estimation from the ref access to make corrections? Best regards
[5 Dec 2024 11:52]
MySQL Verification Team
Thank you, Mr. Yu.