Bug #115359 | Ordering not working with multi-valued composite index | ||
---|---|---|---|
Submitted: | 17 Jun 2024 12:26 | Modified: | 18 Jun 2024 16:16 |
Reporter: | Dishant Trivedi | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S5 (Performance) |
Version: | 8.0.26 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Multi-Valued Indexes, ordering |
[17 Jun 2024 12:26]
Dishant Trivedi
[17 Jun 2024 13:26]
MySQL Verification Team
HI Mr Trivedi, Thank you for your bug report. However, this is not a bug. This is expected behaviour. Composite index can be used for searching or ordering (sorting), only if the column is the first element of the composite key. That is how B+-trees work. Not a bug.
[17 Jun 2024 13:44]
Dishant Trivedi
Hi, Thanks for the reply! I'm afraid that is not the case :) I'm doing a equals (=) condition on the prefix of the key and then doing ordering on the suffix! This should use index range scan right? I can share examples of multiple tables where I use such index and queries. Happy to share if needed!
[17 Jun 2024 14:23]
MySQL Verification Team
Hi Mr. Trivedi, Sorry, but this does not change the facts. Simply, these are two completely different operations and each one is done totally separately of each other. That is the only known algorithm of resolving queries like yours ......
[17 Jun 2024 16:41]
Dishant Trivedi
Can you please share a reference doc for this?
[17 Jun 2024 17:35]
Dishant Trivedi
https://dev.mysql.com/doc/refman/8.4/en/order-by-optimization.html This document highlights one example: In this query, key_part1 is constant, so all rows accessed through the index are in key_part2 order, and an index on (key_part1, key_part2) avoids sorting if the WHERE clause is selective enough to make an index range scan cheaper than a table scan: SELECT * FROM t1 WHERE key_part1 = constant ORDER BY key_part2;
[18 Jun 2024 10:05]
MySQL Verification Team
Hi, Please read our Reference Manual , found in https://dev.mysql.com.
[18 Jun 2024 15:15]
Dishant Trivedi
All I'm trying to understand is that here also we know that the rows the query will access will be in remaining part of index only because of = check on id So why does the same optimisation not apply? Also the link you provided is a homepage link to the MySQL docs! Can you pls be more specific and point out the issue I am facing!
[18 Jun 2024 15:32]
MySQL Verification Team
Hi Mr. Trivedi, This is a forum for the bug reporting. You are supposed to read yourself all the relevant parts of the Reference Manual. You can not apply optimisation when the operations are totally distinct and are in totally different phases of the query optimisation and execution. Not a bug.
[18 Jun 2024 16:16]
Dishant Trivedi
Hello, I am neither denying that this is a bug reporting forum nor am I trying to prove that this is a bug! I may very well be wrong and I accept that!! But if you are making a claim saying this is the expected behavior, you should at the very least try to explain the reasoning for your claim OR (more importantly) share a reference doc backing your claim! Moreover, I have linked a reference to your own documentation that states otherwise - you can atleast take some effort and explain me where I am going wrong! If this is not the right place to ask such question, redirect me to the place where I should be asking this! Just beating around the bush and repeatedly writing "NOT A BUG" won't solve the problem for me :)
[19 Jun 2024 9:55]
MySQL Verification Team
Hi Mr. Trivedi, We wish you to solve your problem. Hence, we are hereby supplying you with necessary info. For details on getting support for MySQL products see http://www.mysql.com/support/ You can also check our forums (free) at http://forums.mysql.com/ Thank you for your interest in MySQL.