Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
N/A
MySQL's WL#1074 mentions a limitation:
when user has two indexes, one ASC and another DESC over the same column, optimizer won't necessary will be able to pick the right index
I suppose it applies to MariaDB as well, even though MDEV-13756 doesn't say so.
However, there might still be room for improvement. At least in some cases MySQL is able to pick up the DESC index out of two, while MariaDB isn't:
# Remove the include if you run the test on MySQL 8.0
--source include/have_innodb.inc
create table t (a int , key aa(a), key ad(a desc )) engine=InnoDB;
insert into t values (1),(5),(2),(8),(4),(6),(7),(9),(3);
explain select * from t order by a desc ;
flush status;
select * from t order by a desc ;
show status like 'Handler_read%' ;
# Cleanup
drop table t;
MariaDB preview-10.8-MDEV-13756-desc-indexes 43444ff5
explain select * from t order by a desc ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index NULL aa 5 NULL 9 Using index
Handler_read_first 0
Handler_read_key 0
Handler_read_last 1
Handler_read_next 0
Handler_read_prev 9
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
MySQL 8.0.23
explain select * from t order by a desc ;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t NULL index NULL ad 5 NULL 10 100.00 Using index
Handler_read_first 1
Handler_read_key 1
Handler_read_last 0
Handler_read_next 9
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 0
ANALYZE/statistics collection doesn't change the outcome.
Same happens on MariaDB with MyISAM/Aria (ASC index is chosen), but it's not comparable to MySQL because MySQL doesn't support DESC indexes on MyISAM tables.
{"report":{"fcp":986.5,"ttfb":187.29999995231628,"pageVisibility":"visible","entityId":106345,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e1b658d3-94f9-4d8c-a8d3-53a55c3fc48d","navigationType":0,"readyForUser":1061.3999999761581,"redirectCount":0,"resourceLoadedEnd":1166.6000000238419,"resourceLoadedStart":193.10000002384186,"resourceTiming":[{"duration":339.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":193.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":193.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":533,"responseStart":0,"secureConnectionStart":0},{"duration":339.8000000715256,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":193.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":193.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":533.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":349.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":193.39999997615814,"connectEnd":193.39999997615814,"connectStart":193.39999997615814,"domainLookupEnd":193.39999997615814,"domainLookupStart":193.39999997615814,"fetchStart":193.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":193.39999997615814,"responseEnd":543.1999999284744,"responseStart":543.1999999284744,"secureConnectionStart":193.39999997615814},{"duration":375.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":193.5,"connectEnd":193.5,"connectStart":193.5,"domainLookupEnd":193.5,"domainLookupStart":193.5,"fetchStart":193.5,"redirectEnd":0,"redirectStart":0,"requestStart":193.5,"responseEnd":568.7999999523163,"responseStart":568.7999999523163,"secureConnectionStart":193.5},{"duration":378.8000000715256,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":193.69999992847443,"connectEnd":193.69999992847443,"connectStart":193.69999992847443,"domainLookupEnd":193.69999992847443,"domainLookupStart":193.69999992847443,"fetchStart":193.69999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":193.69999992847443,"responseEnd":572.5,"responseStart":572.5,"secureConnectionStart":193.69999992847443},{"duration":379.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":193.69999992847443,"connectEnd":193.69999992847443,"connectStart":193.69999992847443,"domainLookupEnd":193.69999992847443,"domainLookupStart":193.69999992847443,"fetchStart":193.69999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":193.69999992847443,"responseEnd":572.8999999761581,"responseStart":572.8999999761581,"secureConnectionStart":193.69999992847443},{"duration":379.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":193.79999995231628,"connectEnd":193.79999995231628,"connectStart":193.79999995231628,"domainLookupEnd":193.79999995231628,"domainLookupStart":193.79999995231628,"fetchStart":193.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":193.79999995231628,"responseEnd":573.2999999523163,"responseStart":573.2999999523163,"secureConnectionStart":193.79999995231628},{"duration":380.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":193.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":193.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":574,"responseStart":0,"secureConnectionStart":0},{"duration":379.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":194.10000002384186,"connectEnd":194.10000002384186,"connectStart":194.10000002384186,"domainLookupEnd":194.10000002384186,"domainLookupStart":194.10000002384186,"fetchStart":194.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":194.10000002384186,"responseEnd":573.6999999284744,"responseStart":573.6999999284744,"secureConnectionStart":194.10000002384186},{"duration":380,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":194.19999992847443,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":194.19999992847443,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":574.1999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":379.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":194.39999997615814,"connectEnd":194.39999997615814,"connectStart":194.39999997615814,"domainLookupEnd":194.39999997615814,"domainLookupStart":194.39999997615814,"fetchStart":194.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":194.39999997615814,"responseEnd":574.2999999523163,"responseStart":574.2999999523163,"secureConnectionStart":194.39999997615814},{"duration":589.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":195.10000002384186,"connectEnd":195.10000002384186,"connectStart":195.10000002384186,"domainLookupEnd":195.10000002384186,"domainLookupStart":195.10000002384186,"fetchStart":195.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":195.10000002384186,"responseEnd":784.1999999284744,"responseStart":784.1999999284744,"secureConnectionStart":195.10000002384186},{"duration":971.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":195.10000002384186,"connectEnd":195.10000002384186,"connectStart":195.10000002384186,"domainLookupEnd":195.10000002384186,"domainLookupStart":195.10000002384186,"fetchStart":195.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":195.10000002384186,"responseEnd":1166.6000000238419,"responseStart":1166.6000000238419,"secureConnectionStart":195.10000002384186},{"duration":387.60000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":778.3999999761581,"connectEnd":778.3999999761581,"connectStart":778.3999999761581,"domainLookupEnd":778.3999999761581,"domainLookupStart":778.3999999761581,"fetchStart":778.3999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":778.3999999761581,"responseEnd":1166,"responseStart":1166,"secureConnectionStart":778.3999999761581}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":38,"responseStart":187,"responseEnd":190,"domLoading":190,"domInteractive":1193,"domContentLoadedEventStart":1193,"domContentLoadedEventEnd":1230,"domComplete":2149,"loadEventStart":2149,"loadEventEnd":2151,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1173.1000000238419},{"name":"bigPipe.sidebar-id.end","time":1174},{"name":"bigPipe.activity-panel-pipe-id.start","time":1174.1999999284744},{"name":"bigPipe.activity-panel-pipe-id.end","time":1176.6000000238419},{"name":"activityTabFullyLoaded","time":1237.1000000238419}],"measures":[],"correlationId":"1ad2abe63f88e0","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":91,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}