Consider this example
create table ten(a int);
|
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
create table t1 (a int, b int, c int);
|
insert into t1 select a,a,a from ten;
|
create table t2 (a int, b int, c int);
|
insert into t2 select a,a,a from ten;
|
|
create table tp (
|
part_id int,
|
a int
|
) partition by list (part_id) (
|
partition p0 values in (0),
|
partition p1 values in (1),
|
partition p2 values in (2),
|
partition p3 values in (3),
|
partition p4 values in (4)
|
);
|
insert into tp select mod(a,5), a from ten;
|
Let's put the partitioned table on the inner side of the outer join, and let the ON expression have a condition that's usable by partition pruning:
explain partitions select * from t1 left join tp on (t1.a=tp.a and tp.part_id=3);
|
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
| 1 | SIMPLE | t1 | NULL | ALL | NULL | NULL | NULL | NULL | 10 | |
|
| 1 | SIMPLE | tp | p3 | ALL | NULL | NULL | NULL | NULL | 2 | Using where; Using join buffer (flat, BNL join) |
|
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
tp.part_id=3 gets us tp.partitions=p3. Good so far.
Now, let's change the outer join to have two tables:
mysql> explain partitions
|
-> select * from t1 left join (tp join t2) on (t1.a=tp.a and tp.a=t2.b and tp.part_id=3);
|
+------+-------------+-------+----------------+------+---------------+------+---------+------+------+--------------------------------------------------------+
|
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+----------------+------+---------------+------+---------+------+------+--------------------------------------------------------+
|
| 1 | SIMPLE | t1 | NULL | ALL | NULL | NULL | NULL | NULL | 10 | |
|
| 1 | SIMPLE | tp | p0,p1,p2,p3,p4 | ALL | NULL | NULL | NULL | NULL | 10 | Using where; Using join buffer (flat, BNL join) |
|
| 1 | SIMPLE | t2 | NULL | ALL | NULL | NULL | NULL | NULL | 10 | Using where; Using join buffer (incremental, BNL join) |
|
+------+-------------+-------+----------------+------+---------------+------+---------+------+------+--------------------------------------------------------+
|
now, tp.partitions includes all partitions even if the ON expression has a condition that restricts it to one.
{"report":{"fcp":661.3999998569489,"ttfb":147.59999990463257,"pageVisibility":"visible","entityId":70358,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"85bdad46-5382-4d71-a217-17aff9a306ed","navigationType":0,"readyForUser":742.2999999523163,"redirectCount":0,"resourceLoadedEnd":712.7999999523163,"resourceLoadedStart":153.29999995231628,"resourceTiming":[{"duration":6.299999952316284,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":153.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":153.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":159.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":6.200000047683716,"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":153.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":153.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":159.79999995231628,"responseStart":0,"secureConnectionStart":0},{"duration":61.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":153.69999980926514,"connectEnd":153.69999980926514,"connectStart":153.69999980926514,"domainLookupEnd":153.69999980926514,"domainLookupStart":153.69999980926514,"fetchStart":153.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":153.69999980926514,"responseEnd":215.29999995231628,"responseStart":215.29999995231628,"secureConnectionStart":153.69999980926514},{"duration":147.10000014305115,"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":153.69999980926514,"connectEnd":153.69999980926514,"connectStart":153.69999980926514,"domainLookupEnd":153.69999980926514,"domainLookupStart":153.69999980926514,"fetchStart":153.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":153.69999980926514,"responseEnd":300.7999999523163,"responseStart":300.7999999523163,"secureConnectionStart":153.69999980926514},{"duration":150.40000009536743,"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.89999985694885,"connectEnd":153.89999985694885,"connectStart":153.89999985694885,"domainLookupEnd":153.89999985694885,"domainLookupStart":153.89999985694885,"fetchStart":153.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":153.89999985694885,"responseEnd":304.2999999523163,"responseStart":304.2999999523163,"secureConnectionStart":153.89999985694885},{"duration":150.89999985694885,"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":154,"connectEnd":154,"connectStart":154,"domainLookupEnd":154,"domainLookupStart":154,"fetchStart":154,"redirectEnd":0,"redirectStart":0,"requestStart":154,"responseEnd":304.89999985694885,"responseStart":304.89999985694885,"secureConnectionStart":154},{"duration":151.29999995231628,"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":154,"connectEnd":154,"connectStart":154,"domainLookupEnd":154,"domainLookupStart":154,"fetchStart":154,"redirectEnd":0,"redirectStart":0,"requestStart":154,"responseEnd":305.2999999523163,"responseStart":305.2999999523163,"secureConnectionStart":154},{"duration":151.70000004768372,"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":154.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":154.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":305.89999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":151.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":154.19999980926514,"connectEnd":154.19999980926514,"connectStart":154.19999980926514,"domainLookupEnd":154.19999980926514,"domainLookupStart":154.19999980926514,"fetchStart":154.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":154.19999980926514,"responseEnd":305.89999985694885,"responseStart":305.89999985694885,"secureConnectionStart":154.19999980926514},{"duration":151.89999985694885,"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":154.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":154.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":306.39999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":152,"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":154.5,"connectEnd":154.5,"connectStart":154.5,"domainLookupEnd":154.5,"domainLookupStart":154.5,"fetchStart":154.5,"redirectEnd":0,"redirectStart":0,"requestStart":154.5,"responseEnd":306.5,"responseStart":306.5,"secureConnectionStart":154.5},{"duration":400.30000019073486,"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":155.19999980926514,"connectEnd":155.19999980926514,"connectStart":155.19999980926514,"domainLookupEnd":155.19999980926514,"domainLookupStart":155.19999980926514,"fetchStart":155.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":155.19999980926514,"responseEnd":555.5,"responseStart":555.5,"secureConnectionStart":155.19999980926514},{"duration":421.39999985694885,"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":155.29999995231628,"connectEnd":155.29999995231628,"connectStart":155.29999995231628,"domainLookupEnd":155.29999995231628,"domainLookupStart":155.29999995231628,"fetchStart":155.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":155.29999995231628,"responseEnd":576.6999998092651,"responseStart":576.6999998092651,"secureConnectionStart":155.29999995231628},{"duration":186.59999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":369.2999999523163,"connectEnd":369.2999999523163,"connectStart":369.2999999523163,"domainLookupEnd":369.2999999523163,"domainLookupStart":369.2999999523163,"fetchStart":369.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":369.2999999523163,"responseEnd":555.8999998569489,"responseStart":555.8999998569489,"secureConnectionStart":369.2999999523163},{"duration":77.40000009536743,"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":618.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":618.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":696,"responseStart":0,"secureConnectionStart":0},{"duration":77.29999995231628,"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":619,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":619,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":696.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":77.30000019073486,"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":619.6999998092651,"connectEnd":619.6999998092651,"connectStart":619.6999998092651,"domainLookupEnd":619.6999998092651,"domainLookupStart":619.6999998092651,"fetchStart":619.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":619.6999998092651,"responseEnd":697,"responseStart":697,"secureConnectionStart":619.6999998092651},{"duration":91.10000014305115,"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":620.1999998092651,"connectEnd":620.1999998092651,"connectStart":620.1999998092651,"domainLookupEnd":620.1999998092651,"domainLookupStart":620.1999998092651,"fetchStart":620.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":620.1999998092651,"responseEnd":711.2999999523163,"responseStart":711.2999999523163,"secureConnectionStart":620.1999998092651},{"duration":92.29999995231628,"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":620.5,"connectEnd":620.5,"connectStart":620.5,"domainLookupEnd":620.5,"domainLookupStart":620.5,"fetchStart":620.5,"redirectEnd":0,"redirectStart":0,"requestStart":620.5,"responseEnd":712.7999999523163,"responseStart":712.6999998092651,"secureConnectionStart":620.5},{"duration":69.20000004768372,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":655.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":655.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":724.2999999523163,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":23,"responseStart":147,"responseEnd":151,"domLoading":151,"domInteractive":813,"domContentLoadedEventStart":813,"domContentLoadedEventEnd":861,"domComplete":1340,"loadEventStart":1340,"loadEventEnd":1342,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":782.5},{"name":"bigPipe.sidebar-id.end","time":783.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":783.3999998569489},{"name":"bigPipe.activity-panel-pipe-id.end","time":785.5},{"name":"activityTabFullyLoaded","time":873.3999998569489}],"measures":[],"correlationId":"a9f4bf4e631556","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":68,"dbReadsTimeInMs":10,"dbConnsTimeInMs":16,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}