Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
None
Component/s:
None
The following query
SELECT (
SELECT MIN(b) FROM t1, t2
WHERE b = a AND
( b = alias1.b OR
EXISTS ( SELECT * FROM t3 )
)
)
FROM t2 alias1, t1 alias2, t1 alias3;
on my machine takes 80 sec and more on the work tree vs 0.5 sec and less on the main 5.5 tree (tried revno 3413 and revno 3402).
bzr version-info
revision-id: timour@askmonty.org-20120518115201-s6byggvesqxcntkd
date: 2012-05-18 14:52:01 +0300
revno: 3404
Reproducible with the default optimizer_switch as well as with all OFF values (except for in_to_exists which is required to execute the query).
Reproducible with MyISAM, Aria, InnoDB.
EXPLAIN on the work tree (with the default optimizer_switch):
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 100.00
1 PRIMARY alias3 ALL NULL NULL NULL NULL 20 100.00 Using join buffer (flat, BNL join)
1 PRIMARY alias1 ALL NULL NULL NULL NULL 100 100.00 Using join buffer (incremental, BNL join)
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 20 100.00
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 100 100.00 Using where; Using join buffer (flat, BNL join)
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1276 Field or reference 'test.alias1.b' of SELECT #2 was resolved in SELECT #1
Note 1003 select <expr_cache><>((select min(`test`.`t2`.`b`) from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`b` = `test`.`t1`.`a`))) AS `(
SELECT MIN(b) FROM t1, t2
WHERE b = a AND
( b = alias1.b OR
EXISTS ( SELECT * FROM t3 )
)
)` from `test`.`t2` `alias1` join `test`.`t1` `alias2` join `test`.`t1` `alias3`
EXPLAIN on the main tree (with the default optimizer_switch):
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 100.00
1 PRIMARY alias3 ALL NULL NULL NULL NULL 20 100.00 Using join buffer (flat, BNL join)
1 PRIMARY alias1 ALL NULL NULL NULL NULL 100 100.00 Using join buffer (incremental, BNL join)
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 20 100.00 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 100 100.00 Using where; Using join buffer (flat, BNL join)
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1276 Field or reference 'test.alias1.b' of SELECT #2 was resolved in SELECT #1
Note 1003 select <expr_cache><`test`.`alias1`.`b`>((select min(`test`.`t2`.`b`) from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and ((`test`.`t1`.`a` = `test`.`alias1`.`b`) or exists(select 1 from `test`.`t3`))))) AS `(
SELECT MIN(b) FROM t1, t2
WHERE b = a AND
( b = alias1.b OR
EXISTS ( SELECT * FROM t3 )
)
)` from `test`.`t2` `alias1` join `test`.`t1` `alias2` join `test`.`t1` `alias3`
Test case:
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES
(1),(7),(4),(7),(0),(2),(9),(4),(0),(9),
(1),(3),(8),(8),(18),(84),(6),(3),(6),(6);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES
(4),(5),(2),(5),(1),(1),(2),(2),(2),(197),
(4),(5),(3),(1),(2),(7),(6),(1),(156),(8),
(7),(2),(6),(2),(1),(0),(7),(5),(7),(2),(1),
(80),(3),(8),(5),(0),(9),(9),(7),(0),(5),
(6),(9),(3),(91),(6),(7),(3),(161),(7),(7),
(6),(5),(8),(7),(2),(1),(3),(6),(6),(5),(0),
(7),(7),(6),(0),(0),(8),(0),(4),(0),(213),
(248),(1),(6),(6),(3),(140),(0),(7),(6),(6),
(8),(5),(8),(7),(3),(7),(3),(8),(0),(1),(3),
(6),(8),(1),(1),(9),(0),(6);
CREATE TABLE t3 (c INT);
INSERT INTO t3 VALUES (8),(3);
SELECT (
SELECT MIN(b) FROM t1, t2
WHERE b = a AND
( b = alias1.b OR
EXISTS ( SELECT * FROM t3 )
)
)
FROM t2 alias1, t1 alias2, t1 alias3;
{"report":{"fcp":840.5999999046326,"ttfb":230.59999990463257,"pageVisibility":"visible","entityId":11800,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"7e407604-7869-42e7-ac95-77eca9e73d12","navigationType":0,"readyForUser":921.3999998569489,"redirectCount":0,"resourceLoadedEnd":458.39999985694885,"resourceLoadedStart":238.09999990463257,"resourceTiming":[{"duration":14.200000047683716,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":238.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":238.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":252.29999995231628,"responseStart":0,"secureConnectionStart":0},{"duration":14.099999904632568,"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":238.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":238.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":252.39999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":160.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":238.39999985694885,"connectEnd":238.39999985694885,"connectStart":238.39999985694885,"domainLookupEnd":238.39999985694885,"domainLookupStart":238.39999985694885,"fetchStart":238.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":255.09999990463257,"responseEnd":398.7999999523163,"responseStart":286.59999990463257,"secureConnectionStart":238.39999985694885},{"duration":219.89999985694885,"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":238.5,"connectEnd":238.5,"connectStart":238.5,"domainLookupEnd":238.5,"domainLookupStart":238.5,"fetchStart":238.5,"redirectEnd":0,"redirectStart":0,"requestStart":256.39999985694885,"responseEnd":458.39999985694885,"responseStart":278.89999985694885,"secureConnectionStart":238.5},{"duration":44.799999952316284,"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":238.70000004768372,"connectEnd":238.70000004768372,"connectStart":238.70000004768372,"domainLookupEnd":238.70000004768372,"domainLookupStart":238.70000004768372,"fetchStart":238.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":257.2999999523163,"responseEnd":283.5,"responseStart":281.7000000476837,"secureConnectionStart":238.70000004768372},{"duration":45.09999990463257,"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":238.79999995231628,"connectEnd":238.79999995231628,"connectStart":238.79999995231628,"domainLookupEnd":238.79999995231628,"domainLookupStart":238.79999995231628,"fetchStart":238.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":258.7000000476837,"responseEnd":283.89999985694885,"responseStart":282.39999985694885,"secureConnectionStart":238.79999995231628},{"duration":18,"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":238.89999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":238.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":256.89999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":52.90000009536743,"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":238.89999985694885,"connectEnd":238.89999985694885,"connectStart":238.89999985694885,"domainLookupEnd":238.89999985694885,"domainLookupStart":238.89999985694885,"fetchStart":238.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":259.89999985694885,"responseEnd":291.7999999523163,"responseStart":290.2999999523163,"secureConnectionStart":238.89999985694885},{"duration":55,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":239.09999990463257,"connectEnd":239.09999990463257,"connectStart":239.09999990463257,"domainLookupEnd":239.09999990463257,"domainLookupStart":239.09999990463257,"fetchStart":239.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":263.2000000476837,"responseEnd":294.09999990463257,"responseStart":292.2999999523163,"secureConnectionStart":239.09999990463257},{"duration":19.399999856948853,"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":239.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":239.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":258.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":55.19999980926514,"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":239.20000004768372,"connectEnd":239.20000004768372,"connectStart":239.20000004768372,"domainLookupEnd":239.20000004768372,"domainLookupStart":239.20000004768372,"fetchStart":239.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":264.2000000476837,"responseEnd":294.39999985694885,"responseStart":292.7999999523163,"secureConnectionStart":239.20000004768372},{"duration":190.89999985694885,"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":251,"connectEnd":251,"connectStart":251,"domainLookupEnd":251,"domainLookupStart":251,"fetchStart":251,"redirectEnd":0,"redirectStart":0,"requestStart":288.5,"responseEnd":441.89999985694885,"responseStart":439.5,"secureConnectionStart":251},{"duration":191.20000004768372,"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":251.09999990463257,"connectEnd":251.09999990463257,"connectStart":251.09999990463257,"domainLookupEnd":251.09999990463257,"domainLookupStart":251.09999990463257,"fetchStart":251.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":288.7000000476837,"responseEnd":442.2999999523163,"responseStart":440.59999990463257,"secureConnectionStart":251.09999990463257},{"duration":178.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":588.8999998569489,"connectEnd":588.8999998569489,"connectStart":588.8999998569489,"domainLookupEnd":588.8999998569489,"domainLookupStart":588.8999998569489,"fetchStart":588.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":738.2999999523163,"responseEnd":767.7999999523163,"responseStart":766.7000000476837,"secureConnectionStart":588.8999998569489}],"fetchStart":0,"domainLookupStart":29,"domainLookupEnd":32,"connectStart":32,"connectEnd":50,"secureConnectionStart":40,"requestStart":52,"responseStart":231,"responseEnd":250,"domLoading":234,"domInteractive":988,"domContentLoadedEventStart":988,"domContentLoadedEventEnd":1032,"domComplete":2043,"loadEventStart":2043,"loadEventEnd":2043,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":965.7000000476837},{"name":"bigPipe.sidebar-id.end","time":966.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":966.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":969.3999998569489},{"name":"activityTabFullyLoaded","time":1039.7000000476837}],"measures":[],"correlationId":"c6d0420c9ecbf5","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":106,"dbReadsTimeInMs":9,"dbConnsTimeInMs":16,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}