This is a followup to MDEV-25858.
The fix for MDEV-25858 handles backward index scan but not forward index scan.
Take the testcase from MDEV-25858 (from order_by_innodb.test), remove DESC from ORDER BY, and run EXPLAIN
explain
|
select
|
t1.id,t2.id
|
from
|
t1 left join
|
t2 on t2.id2 = t1.id and
|
t2.id = (select dd.id
|
from t2 dd
|
where
|
dd.id2 = t1.id and
|
d1 > '2019-02-06 00:00:00'
|
order by
|
dd.d1 , dd.d2 , dd.id limit 1
|
);
|
This shows:
id select_type table type possible_keys key key_len ref rows Extra
|
1 PRIMARY t1 index NULL PRIMARY 4 NULL 3 Using index
|
1 PRIMARY t2 eq_ref PRIMARY,id2 PRIMARY 4 func 1 Using where
|
2 DEPENDENT SUBQUERY dd ALL id2,for_latest_sort for_latest_sort 6 NULL 3 Range checked for each record (index map: 0x6)
|
Note the last line: Range checked for each record is used, but there are no provisions for producing rows in the order specified by the ORDER BY ... LIMIT clause.
- relates to
-
MDEV-25858
Query results are incorrect when indexes are added.
-
-
Closed
{"report":{"fcp":1002.0999999046326,"ttfb":211.19999980926514,"pageVisibility":"visible","entityId":106019,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"f9612cf9-b897-4002-9b07-38aefb6f98fe","navigationType":0,"readyForUser":1124.7999999523163,"redirectCount":0,"resourceLoadedEnd":1103.7999999523163,"resourceLoadedStart":231.79999995231628,"resourceTiming":[{"duration":69.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":231.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":231.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":301,"responseStart":0,"secureConnectionStart":0},{"duration":69.20000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":232.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":232.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":301.39999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":165.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":232.29999995231628,"connectEnd":232.29999995231628,"connectStart":232.29999995231628,"domainLookupEnd":232.29999995231628,"domainLookupStart":232.29999995231628,"fetchStart":232.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":232.29999995231628,"responseEnd":397.7999999523163,"responseStart":397.7999999523163,"secureConnectionStart":232.29999995231628},{"duration":228,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":232.59999990463257,"connectEnd":232.59999990463257,"connectStart":232.59999990463257,"domainLookupEnd":232.59999990463257,"domainLookupStart":232.59999990463257,"fetchStart":232.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":232.59999990463257,"responseEnd":460.59999990463257,"responseStart":460.5,"secureConnectionStart":232.59999990463257},{"duration":233.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":232.89999985694885,"connectEnd":232.89999985694885,"connectStart":232.89999985694885,"domainLookupEnd":232.89999985694885,"domainLookupStart":232.89999985694885,"fetchStart":232.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":232.89999985694885,"responseEnd":466.09999990463257,"responseStart":466.09999990463257,"secureConnectionStart":232.89999985694885},{"duration":233.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":233.09999990463257,"connectEnd":233.09999990463257,"connectStart":233.09999990463257,"domainLookupEnd":233.09999990463257,"domainLookupStart":233.09999990463257,"fetchStart":233.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":233.09999990463257,"responseEnd":467,"responseStart":467,"secureConnectionStart":233.09999990463257},{"duration":234.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":233.19999980926514,"connectEnd":233.19999980926514,"connectStart":233.19999980926514,"domainLookupEnd":233.19999980926514,"domainLookupStart":233.19999980926514,"fetchStart":233.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":233.19999980926514,"responseEnd":467.89999985694885,"responseStart":467.89999985694885,"secureConnectionStart":233.19999980926514},{"duration":331.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":233.39999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":233.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":564.8999998569489,"responseStart":0,"secureConnectionStart":0},{"duration":234.79999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":233.59999990463257,"connectEnd":233.59999990463257,"connectStart":233.59999990463257,"domainLookupEnd":233.59999990463257,"domainLookupStart":233.59999990463257,"fetchStart":233.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":233.59999990463257,"responseEnd":468.39999985694885,"responseStart":468.39999985694885,"secureConnectionStart":233.59999990463257},{"duration":331.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":233.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":233.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":565.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":235.10000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":233.89999985694885,"connectEnd":233.89999985694885,"connectStart":233.89999985694885,"domainLookupEnd":233.89999985694885,"domainLookupStart":233.89999985694885,"fetchStart":233.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":233.89999985694885,"responseEnd":469,"responseStart":469,"secureConnectionStart":233.89999985694885},{"duration":521,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":234.79999995231628,"connectEnd":234.79999995231628,"connectStart":234.79999995231628,"domainLookupEnd":234.79999995231628,"domainLookupStart":234.79999995231628,"fetchStart":234.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":234.79999995231628,"responseEnd":755.7999999523163,"responseStart":755.7999999523163,"secureConnectionStart":234.79999995231628},{"duration":868.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":234.89999985694885,"connectEnd":234.89999985694885,"connectStart":234.89999985694885,"domainLookupEnd":234.89999985694885,"domainLookupStart":234.89999985694885,"fetchStart":234.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":234.89999985694885,"responseEnd":1103.7999999523163,"responseStart":1103.7999999523163,"secureConnectionStart":234.89999985694885},{"duration":235.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":596.5999999046326,"connectEnd":596.5999999046326,"connectStart":596.5999999046326,"domainLookupEnd":596.5999999046326,"domainLookupStart":596.5999999046326,"fetchStart":596.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":596.5999999046326,"responseEnd":832.5,"responseStart":832.5,"secureConnectionStart":596.5999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":59,"responseStart":211,"responseEnd":225,"domLoading":227,"domInteractive":1223,"domContentLoadedEventStart":1223,"domContentLoadedEventEnd":1268,"domComplete":2508,"loadEventStart":2508,"loadEventEnd":2510,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1197},{"name":"bigPipe.sidebar-id.end","time":1197.8999998569489},{"name":"bigPipe.activity-panel-pipe-id.start","time":1198},{"name":"bigPipe.activity-panel-pipe-id.end","time":1200.7999999523163},{"name":"activityTabFullyLoaded","time":1277}],"measures":[],"correlationId":"6c4c23cd7d2669","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":92,"dbReadsTimeInMs":11,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}