Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
None
Component/s:
None
The following query
SELECT * FROM t1 AS alias
WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b );
on the test data returns 1 row with exists_to_in=off, 2 rows with exists_to_in=on + materialization=on + semijoin=on, and 0 rows with exists_in=on + materialization=on + semijon=off. The correct result is 1 row.
bzr version-info
revision-id: sanja@montyprogram.com-20120430093355-4yrpta86g97g6rhb
date: 2012-04-30 12:33:55 +0300
build-date: 2012-05-02 17:50:48 +0400
revno: 3390
Default optimizer_switch + exists_to_in=ON:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=off,exists_to_in=on
EXPLAINs:
With exists_to_in=ON, materialization=ON, everything else OFF (empty result set instead of 1 row):
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY alias ALL NULL NULL NULL NULL 2 100.00 Using where
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.alias.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.alias.b' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`alias`.`a` AS `a`,`test`.`alias`.`b` AS `b` from `test`.`t1` `alias` where <in_optimizer>(`test`.`alias`.`b`,`test`.`alias`.`b` in ( <materialize> (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`a` > `test`.`alias`.`a`) ), <primary_index_lookup>(`test`.`alias`.`b` in <temporary table> on distinct_key where ((`test`.`alias`.`b` = `<subquery2>`.`a`)))))
With exists_to_in=ON, materialization=ON, semijoin=ON, everything else OFF (2 rows instead of 1 row):
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY alias ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 Using where
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1276 Field or reference 'test.alias.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.alias.b' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`alias`.`a` AS `a`,`test`.`alias`.`b` AS `b` from `test`.`t1` `alias` semi join (`test`.`t1`) where ((`test`.`t1`.`a` > `test`.`alias`.`a`))
With default optimizer_switch + exists_to_in=ON (2 rows instead of 1 row):
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY alias ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 Using where
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1276 Field or reference 'test.alias.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.alias.b' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`alias`.`a` AS `a`,`test`.`alias`.`b` AS `b` from `test`.`t1` `alias` semi join (`test`.`t1`) where ((`test`.`t1`.`a` > `test`.`alias`.`a`))
Test case:
SET optimizer_switch='exists_to_in=on';
CREATE TABLE t1 ( a VARCHAR(1), b VARCHAR(1) );
INSERT INTO t1 VALUES ('v','v'),('s','v');
SELECT * FROM t1 AS alias
WHERE EXISTS ( SELECT * FROM t1 WHERE a > alias.a AND a = alias.b );
Expected result:
Actual result differs depending on the optimizer_switch (see above).
relates to
MDEV-38
NOT EXISTS to IN (part of exists2in transformation for 10.0)
Closed
{"report":{"fcp":663.9000005722046,"ttfb":146.80000019073486,"pageVisibility":"visible","entityId":11538,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"b97174a5-3ddf-4def-9b87-7b57143f1c06","navigationType":0,"readyForUser":727,"redirectCount":0,"resourceLoadedEnd":693.4000005722046,"resourceLoadedStart":152.30000019073486,"resourceTiming":[{"duration":6.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":152.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":152.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":158.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":6.300000190734863,"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":152.60000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":152.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":158.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":58.60000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":152.80000019073486,"connectEnd":152.80000019073486,"connectStart":152.80000019073486,"domainLookupEnd":152.80000019073486,"domainLookupStart":152.80000019073486,"fetchStart":152.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":152.80000019073486,"responseEnd":211.4000005722046,"responseStart":211.4000005722046,"secureConnectionStart":152.80000019073486},{"duration":107.59999942779541,"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":152.9000005722046,"connectEnd":152.9000005722046,"connectStart":152.9000005722046,"domainLookupEnd":152.9000005722046,"domainLookupStart":152.9000005722046,"fetchStart":152.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":152.9000005722046,"responseEnd":260.5,"responseStart":260.5,"secureConnectionStart":152.9000005722046},{"duration":110.80000019073486,"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":153,"connectEnd":153,"connectStart":153,"domainLookupEnd":153,"domainLookupStart":153,"fetchStart":153,"redirectEnd":0,"redirectStart":0,"requestStart":153,"responseEnd":263.80000019073486,"responseStart":263.80000019073486,"secureConnectionStart":153},{"duration":111.69999980926514,"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":153.10000038146973,"connectEnd":153.10000038146973,"connectStart":153.10000038146973,"domainLookupEnd":153.10000038146973,"domainLookupStart":153.10000038146973,"fetchStart":153.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":153.10000038146973,"responseEnd":264.80000019073486,"responseStart":264.80000019073486,"secureConnectionStart":153.10000038146973},{"duration":112.39999961853027,"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":153.10000038146973,"connectEnd":153.10000038146973,"connectStart":153.10000038146973,"domainLookupEnd":153.10000038146973,"domainLookupStart":153.10000038146973,"fetchStart":153.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":153.10000038146973,"responseEnd":265.5,"responseStart":265.5,"secureConnectionStart":153.10000038146973},{"duration":113,"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":153.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":153.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":266.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":113,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":153.30000019073486,"connectEnd":153.30000019073486,"connectStart":153.30000019073486,"domainLookupEnd":153.30000019073486,"domainLookupStart":153.30000019073486,"fetchStart":153.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":153.30000019073486,"responseEnd":266.30000019073486,"responseStart":266.19999980926514,"secureConnectionStart":153.30000019073486},{"duration":113.59999942779541,"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":153.4000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":153.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":267,"responseStart":0,"secureConnectionStart":0},{"duration":113.60000038146973,"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":153.5,"connectEnd":153.5,"connectStart":153.5,"domainLookupEnd":153.5,"domainLookupStart":153.5,"fetchStart":153.5,"redirectEnd":0,"redirectStart":0,"requestStart":153.5,"responseEnd":267.1000003814697,"responseStart":267.1000003814697,"secureConnectionStart":153.5},{"duration":338.5,"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":158.9000005722046,"connectEnd":158.9000005722046,"connectStart":158.9000005722046,"domainLookupEnd":158.9000005722046,"domainLookupStart":158.9000005722046,"fetchStart":158.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":158.9000005722046,"responseEnd":497.4000005722046,"responseStart":497.4000005722046,"secureConnectionStart":158.9000005722046},{"duration":411.80000019073486,"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":159,"connectEnd":159,"connectStart":159,"domainLookupEnd":159,"domainLookupStart":159,"fetchStart":159,"redirectEnd":0,"redirectStart":0,"requestStart":159,"responseEnd":570.8000001907349,"responseStart":570.8000001907349,"secureConnectionStart":159},{"duration":146.5999994277954,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":420.6000003814697,"connectEnd":420.6000003814697,"connectStart":420.6000003814697,"domainLookupEnd":420.6000003814697,"domainLookupStart":420.6000003814697,"fetchStart":420.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":420.6000003814697,"responseEnd":567.1999998092651,"responseStart":567.1999998092651,"secureConnectionStart":420.6000003814697},{"duration":42.30000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":637,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":637,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":679.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":32,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":649.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":649.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":681.1999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":31.899999618530273,"initiatorType":"link","name":"https://jira.mariadb.org/s/50bc9be5bfead1a25e72c1a9338c94f6-CDN/lu2bu7/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/css/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":649.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":649.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":681.5,"responseStart":0,"secureConnectionStart":0},{"duration":32.79999923706055,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":650.4000005722046,"connectEnd":650.4000005722046,"connectStart":650.4000005722046,"domainLookupEnd":650.4000005722046,"domainLookupStart":650.4000005722046,"fetchStart":650.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":650.4000005722046,"responseEnd":683.1999998092651,"responseStart":683.1999998092651,"secureConnectionStart":650.4000005722046},{"duration":41.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":650.6999998092651,"connectEnd":650.6999998092651,"connectStart":650.6999998092651,"domainLookupEnd":650.6999998092651,"domainLookupStart":650.6999998092651,"fetchStart":650.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":650.6999998092651,"responseEnd":692,"responseStart":692,"secureConnectionStart":650.6999998092651},{"duration":42.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/86ee9bbc76cd1bcd8556fcdcf46241c9-CDN/lu2bu7/820016/12ta74/e108c7645258ccb43280ed3404e3e949/_/download/contextbatch/js/com.atlassian.jira.plugins.jira-development-integration-plugin:0,-_super,-jira.view.issue,-jira.global,-jira.general,-jira.browse.project,-project.issue.navigator,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":651.1000003814697,"connectEnd":651.1000003814697,"connectStart":651.1000003814697,"domainLookupEnd":651.1000003814697,"domainLookupStart":651.1000003814697,"fetchStart":651.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":651.1000003814697,"responseEnd":693.4000005722046,"responseStart":693.4000005722046,"secureConnectionStart":651.1000003814697}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":18,"responseStart":146,"responseEnd":154,"domLoading":150,"domInteractive":795,"domContentLoadedEventStart":795,"domContentLoadedEventEnd":839,"domComplete":1111,"loadEventStart":1111,"loadEventEnd":1112,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":764.9000005722046},{"name":"bigPipe.sidebar-id.end","time":765.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.start","time":765.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":768},{"name":"activityTabFullyLoaded","time":847.5}],"measures":[],"correlationId":"a8f03728566deb","effectiveType":"4g","downlink":9.2,"rtt":0,"serverDuration":70,"dbReadsTimeInMs":11,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}