Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
10.3(EOL) , 10.4(EOL) , 10.5 , 10.6 , 10.7(EOL) , 10.8(EOL) , 10.9(EOL) , 10.10(EOL) , 10.11
CREATE TABLE t1 (a INT );
INSERT INTO t1 VALUES (8),(9);
CREATE TABLE t2 (b INT );
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t3 (c INT , d DATE );
INSERT INTO t3 VALUES (2, '2022-12-12' ),(3, '2023-12-12' );
SELECT c, ( SELECT MIN (a) FROM t1 WHERE t3.c IN ( SELECT b FROM t2)) AS f1, GROUP_CONCAT(d) AS f2 FROM t3 GROUP BY c, f1 ORDER BY f2;
10.3 0ca3aaa7
SELECT c, ( SELECT MIN (a) FROM t1 WHERE t3.c IN ( SELECT b FROM t2)) AS f1, GROUP_CONCAT(d) AS f2 FROM t3 GROUP BY c, f1 ORDER BY f2;
c f1 f2
2 NULL 2022-12-12
3 NULL 2023-12-12
EXPLAIN EXTENDED SELECT c, ( SELECT MIN (a) FROM t1 WHERE t3.c IN ( SELECT b FROM t2)) AS f1, GROUP_CONCAT(d) AS f2 FROM t3 GROUP BY c, f1 ORDER BY f2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using temporary ; Using filesort
2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join )
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1276 Field or reference 'test.t3.c' of SELECT #2 was resolved in SELECT #1
Note 1003 /* select#1 */ select `test`.`t3`.`c` AS `c`,<expr_cache><`test`.`t3`.`c`>(( /* select#2 */ select min (`test`.`t1`.`a`) from `test`.`t1` semi join (`test`.`t2`) where `test`.`t3`.`c` = `test`.`t2`.`b`)) AS `f1`,group_concat(`test`.`t3`.`d` separator ',' ) AS `f2` from `test`.`t3` group by `test`.`t3`.`c`,<expr_cache><`test`.`t3`.`c`>(( /* select#2 */ select min (`test`.`t1`.`a`) from `test`.`t1` semi join (`test`.`t2`) where `test`.`t3`.`c` = `test`.`t2`.`b`)) order by group_concat(`test`.`t3`.`d` separator ',' )
Expected result is
c f1 f2
2 8 2022-12-12
3 NULL 2023-12-12
On 10.3 it can be achieved with materialization=off .
Reproducible with at least MyISAM and InnoDB.
Reproducible on 5.5 (and materialization=off doesn't seem to help there).
Not reproducible on MySQL (5.6, 5.7, 8.0).
On bb-11.0 (a.k.a improved selectivity tree MDEV-26974 ) the plan with default settings is different and the result is correct, but the wrong one can still be triggered with firstmatch=off .
{"report":{"fcp":1278.2999997138977,"ttfb":579.9000000953674,"pageVisibility":"visible","entityId":117952,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"ca6d4ace-1074-46b0-9cca-d895026a4e5c","navigationType":0,"readyForUser":1374.4000000953674,"redirectCount":0,"resourceLoadedEnd":965.4000000953674,"resourceLoadedStart":591.2999997138977,"resourceTiming":[{"duration":18.700000286102295,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":591.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":591.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":610,"responseStart":0,"secureConnectionStart":0},{"duration":18.800000190734863,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":591.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":591.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":610.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":208.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":591.7999997138977,"connectEnd":591.7999997138977,"connectStart":591.7999997138977,"domainLookupEnd":591.7999997138977,"domainLookupStart":591.7999997138977,"fetchStart":591.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":611.1999998092651,"responseEnd":800,"responseStart":628.7999997138977,"secureConnectionStart":591.7999997138977},{"duration":373.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":592,"connectEnd":592,"connectStart":592,"domainLookupEnd":592,"domainLookupStart":592,"fetchStart":592,"redirectEnd":0,"redirectStart":0,"requestStart":611.5999999046326,"responseEnd":965.4000000953674,"responseStart":630.6999998092651,"secureConnectionStart":592},{"duration":42.69999980926514,"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":592.0999999046326,"connectEnd":592.0999999046326,"connectStart":592.0999999046326,"domainLookupEnd":592.0999999046326,"domainLookupStart":592.0999999046326,"fetchStart":592.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":612.2999997138977,"responseEnd":634.7999997138977,"responseStart":632.5,"secureConnectionStart":592.0999999046326},{"duration":46.89999961853027,"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":592.4000000953674,"connectEnd":592.4000000953674,"connectStart":592.4000000953674,"domainLookupEnd":592.4000000953674,"domainLookupStart":592.4000000953674,"fetchStart":592.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":612.6999998092651,"responseEnd":639.2999997138977,"responseStart":633.0999999046326,"secureConnectionStart":592.4000000953674},{"duration":47.299999713897705,"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":592.5,"connectEnd":592.5,"connectStart":592.5,"domainLookupEnd":592.5,"domainLookupStart":592.5,"fetchStart":592.5,"redirectEnd":0,"redirectStart":0,"requestStart":613.9000000953674,"responseEnd":639.7999997138977,"responseStart":635.0999999046326,"secureConnectionStart":592.5},{"duration":21.40000009536743,"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":592.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":592.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":614.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":47.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":592.9000000953674,"connectEnd":592.9000000953674,"connectStart":592.9000000953674,"domainLookupEnd":592.9000000953674,"domainLookupStart":592.9000000953674,"fetchStart":592.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":616.6999998092651,"responseEnd":640.0999999046326,"responseStart":636.5999999046326,"secureConnectionStart":592.9000000953674},{"duration":22.300000190734863,"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":593.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":593.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":615.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":54.59999990463257,"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":593.1999998092651,"connectEnd":593.1999998092651,"connectStart":593.1999998092651,"domainLookupEnd":593.1999998092651,"domainLookupStart":593.1999998092651,"fetchStart":593.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":619.0999999046326,"responseEnd":647.7999997138977,"responseStart":640.7999997138977,"secureConnectionStart":593.1999998092651},{"duration":344.80000019073486,"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":615.1999998092651,"connectEnd":615.1999998092651,"connectStart":615.1999998092651,"domainLookupEnd":615.1999998092651,"domainLookupStart":615.1999998092651,"fetchStart":615.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":646.5999999046326,"responseEnd":960,"responseStart":951.4000000953674,"secureConnectionStart":615.1999998092651},{"duration":339.3999996185303,"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":620.9000000953674,"connectEnd":620.9000000953674,"connectStart":620.9000000953674,"domainLookupEnd":620.9000000953674,"domainLookupStart":620.9000000953674,"fetchStart":620.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":680.5,"responseEnd":960.2999997138977,"responseStart":952,"secureConnectionStart":620.9000000953674},{"duration":111.39999961853027,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":953.9000000953674,"connectEnd":953.9000000953674,"connectStart":953.9000000953674,"domainLookupEnd":953.9000000953674,"domainLookupStart":953.9000000953674,"fetchStart":953.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1033.6999998092651,"responseEnd":1065.2999997138977,"responseStart":1064.5,"secureConnectionStart":953.9000000953674},{"duration":258,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1198.4000000953674,"connectEnd":1198.4000000953674,"connectStart":1198.4000000953674,"domainLookupEnd":1198.4000000953674,"domainLookupStart":1198.4000000953674,"fetchStart":1198.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1424.5999999046326,"responseEnd":1456.4000000953674,"responseStart":1455.5999999046326,"secureConnectionStart":1198.4000000953674},{"duration":216.59999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1258.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1258.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1475,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":331,"responseStart":580,"responseEnd":621,"domLoading":587,"domInteractive":1489,"domContentLoadedEventStart":1489,"domContentLoadedEventEnd":1548,"domComplete":2286,"loadEventStart":2286,"loadEventEnd":2286,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1460},{"name":"bigPipe.sidebar-id.end","time":1460.7999997138977},{"name":"bigPipe.activity-panel-pipe-id.start","time":1461},{"name":"bigPipe.activity-panel-pipe-id.end","time":1463.5999999046326},{"name":"activityTabFullyLoaded","time":1556.2999997138977}],"measures":[],"correlationId":"c564585bcf00ac","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":125,"dbReadsTimeInMs":9,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}