[MDEV-26996] Support descending indexes in the range optimizer Created: 2021-11-08 Updated: 2023-03-21 Resolved: 2022-02-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | 10.8.1 |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
| Comments |
| Comment by Sergei Krivonos (Inactive) [ 2021-11-12 ] | ||||||||||||||||||||
|
Igor noticed that asc/desc distinction is irrelevant for optimizer because both has same estimated performance. | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-11-16 ] | ||||||||||||||||||||
|
I think he's missing the point.
if the index is (kp1 ASC, kp2 ASC), then the range is
but if the index is (kp1 ASC, kp2 DESC), then one can only extract this range:
And I think determining this is to be done on the SQL layer. | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-12-05 ] | ||||||||||||||||||||
|
Note: My suggestion in the description breaks down on SEL_ARG::store_min_key()
Consider an index
Consider a call
It should get the minimum for kp1, maximum for kp2, minimum for kp3 and so forth. | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-12-05 ] | ||||||||||||||||||||
|
... which means that SEL_ARG::store_min_key() should have knowledge about which keyparts are inverted and which are not. | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-12-10 ] | ||||||||||||||||||||
|
An interesting property of MySQL's implementation. Consider an example:
The ranges to be scanned are: d=8, d=4, d=2. But the handler::multi_range_read_info_const() call receives them in the ascending order: d=2, d=4, d=8. This might be ok for MySQL, their handler::multi_range_read_info_const() treats each range independently. But is it good for MariaDB's handler::multi_range_read_info_const which tries to take into account gap size between adjacent ranges? | ||||||||||||||||||||
| Comment by Sergei Petrunia [ 2021-12-14 ] | ||||||||||||||||||||
|
Ready for testing in preview-10.8- | ||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-12-16 ] | ||||||||||||||||||||
|
As of today, the correct branch name is preview-10.8- | ||||||||||||||||||||
| Comment by Elena Stepanova [ 2022-01-26 ] | ||||||||||||||||||||
|
Tested in the scope of |