Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
None
Component/s:
None
For the following query
let $query =
SELECT SUM(b) FROM ( SELECT * FROM t1 ) AS alias1, t2
WHERE b <= ANY (
SELECT a FROM t1
WHERE a = b + SLEEP(0.2) OR a >= ( SELECT SUM(b) FROM t2 )
)
EXPLAIN returns
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using index
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 DEPENDENT SUBQUERY t1 index a a 4 NULL 2 Using where; Using index
4 SUBQUERY t2 ALL NULL NULL NULL NULL 2
and SHOW EXPLAIN produces
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using index
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 DEPENDENT SUBQUERY t1 ALL a NULL NULL NULL 2 Range checked for each record (index map: 0x1)
4 SUBQUERY t2 ALL NULL NULL NULL NULL 2
As always, SLEEP in the query is not essential, it just makes the query a bit longer and allows to catch it by SHOW EXPLAIN.
bzr version-info (5.5-show-explain-test1)
revision-id: psergey@askmonty.org-20120719215203-m2p9cbqb37n0th7n
date: 2012-07-20 01:52:03 +0400
build-date: 2012-07-24 04:43:23 +0400
revno: 3456
Test case:
CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (7),(0);
CREATE TABLE t2 (b INT NOT NULL) ENGINE=MyISAM;
INSERT INTO t2 VALUES (0),(8);
let $query =
SELECT SUM(b) FROM ( SELECT * FROM t1 ) AS alias1, t2
WHERE b <= ANY (
SELECT a FROM t1
WHERE a = b + SLEEP(0.2) OR a >= ( SELECT SUM(b) FROM t2 )
);
eval EXPLAIN $query;
--echo #---------------
--echo # SHOW EXPLAIN output:
--connect (con1,localhost,root,,)
--let $con_id = `SELECT CONNECTION_ID()`
--let $trials = 50
--disable_query_log
while ($trials)
{
--dec $trials
--let $run = 1000
--send_eval $query
--connection default
while ($run)
{
--error 0,1932
eval SHOW EXPLAIN FOR $con_id;
--dec $run
if (!$mysql_errno)
{
--let $run = 0
--let $trials = 0
--let $found = 1
}
}
--disable_result_log
--connection con1
--reap
--enable_result_log
}
if (!$found)
{
--echo ########### Could not catch the query by SHOW EXPLAIN, try again #############
}
DROP TABLE t1, t2;
relates to
MDEV-165
MWL#182: Explain running statements: finish coding, submit for review
Closed
{"report":{"fcp":830.8000001907349,"ttfb":223.80000019073486,"pageVisibility":"visible","entityId":13479,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"173ef846-9d23-44d5-85e1-081471aabe5a","navigationType":0,"readyForUser":918.1999998092651,"redirectCount":0,"resourceLoadedEnd":1629,"resourceLoadedStart":229.60000038146973,"resourceTiming":[{"duration":145.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":229.60000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":229.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":374.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":145.5,"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":229.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":229.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":375.30000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":154.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":230,"connectEnd":230,"connectStart":230,"domainLookupEnd":230,"domainLookupStart":230,"fetchStart":230,"redirectEnd":0,"redirectStart":0,"requestStart":230,"responseEnd":384.1000003814697,"responseStart":384.1000003814697,"secureConnectionStart":230},{"duration":214.19999980926514,"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":230.10000038146973,"connectEnd":230.10000038146973,"connectStart":230.10000038146973,"domainLookupEnd":230.10000038146973,"domainLookupStart":230.10000038146973,"fetchStart":230.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":230.10000038146973,"responseEnd":444.30000019073486,"responseStart":444.30000019073486,"secureConnectionStart":230.10000038146973},{"duration":217.5999994277954,"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":230.4000005722046,"connectEnd":230.4000005722046,"connectStart":230.4000005722046,"domainLookupEnd":230.4000005722046,"domainLookupStart":230.4000005722046,"fetchStart":230.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":230.4000005722046,"responseEnd":448,"responseStart":448,"secureConnectionStart":230.4000005722046},{"duration":217.9000005722046,"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":230.5,"connectEnd":230.5,"connectStart":230.5,"domainLookupEnd":230.5,"domainLookupStart":230.5,"fetchStart":230.5,"redirectEnd":0,"redirectStart":0,"requestStart":230.5,"responseEnd":448.4000005722046,"responseStart":448.4000005722046,"secureConnectionStart":230.5},{"duration":218.10000038146973,"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":230.69999980926514,"connectEnd":230.69999980926514,"connectStart":230.69999980926514,"domainLookupEnd":230.69999980926514,"domainLookupStart":230.69999980926514,"fetchStart":230.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":230.69999980926514,"responseEnd":448.80000019073486,"responseStart":448.80000019073486,"secureConnectionStart":230.69999980926514},{"duration":294.19999980926514,"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":230.9000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":230.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":525.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":218.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":231.10000038146973,"connectEnd":231.10000038146973,"connectStart":231.10000038146973,"domainLookupEnd":231.10000038146973,"domainLookupStart":231.10000038146973,"fetchStart":231.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":231.10000038146973,"responseEnd":449.30000019073486,"responseStart":449.30000019073486,"secureConnectionStart":231.10000038146973},{"duration":293.8999996185303,"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":231.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":231.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":525.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":218.5,"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":231.4000005722046,"connectEnd":231.4000005722046,"connectStart":231.4000005722046,"domainLookupEnd":231.4000005722046,"domainLookupStart":231.4000005722046,"fetchStart":231.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":231.4000005722046,"responseEnd":449.9000005722046,"responseStart":449.9000005722046,"secureConnectionStart":231.4000005722046},{"duration":426.19999980926514,"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":232.4000005722046,"connectEnd":232.4000005722046,"connectStart":232.4000005722046,"domainLookupEnd":232.4000005722046,"domainLookupStart":232.4000005722046,"fetchStart":232.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":232.4000005722046,"responseEnd":658.6000003814697,"responseStart":658.6000003814697,"secureConnectionStart":232.4000005722046},{"duration":1396.5,"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":232.5,"connectEnd":232.5,"connectStart":232.5,"domainLookupEnd":232.5,"domainLookupStart":232.5,"fetchStart":232.5,"redirectEnd":0,"redirectStart":0,"requestStart":232.5,"responseEnd":1629,"responseStart":1629,"secureConnectionStart":232.5},{"duration":257.29999923706055,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":551.4000005722046,"connectEnd":551.4000005722046,"connectStart":551.4000005722046,"domainLookupEnd":551.4000005722046,"domainLookupStart":551.4000005722046,"fetchStart":551.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":551.4000005722046,"responseEnd":808.6999998092651,"responseStart":808.6999998092651,"secureConnectionStart":551.4000005722046}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":48,"responseStart":224,"responseEnd":225,"domLoading":227,"domInteractive":1646,"domContentLoadedEventStart":1646,"domContentLoadedEventEnd":1686,"domComplete":2460,"loadEventStart":2460,"loadEventEnd":2462,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1633.6000003814697},{"name":"bigPipe.sidebar-id.end","time":1634.4000005722046},{"name":"bigPipe.activity-panel-pipe-id.start","time":1634.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1636.9000005722046},{"name":"activityTabFullyLoaded","time":1692.8000001907349}],"measures":[],"correlationId":"45f08a515ab9fa","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":103,"dbReadsTimeInMs":9,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}