Here is the test (picked from derived_cond_pushdown.test in the main suite)
CREATE TABLE t1 (pk1 INT PRIMARY KEY, f INT) ENGINE=Aria;
|
INSERT INTO t1 VALUES (1,0),(2,0);
|
CREATE TABLE t2 (pk2 INT PRIMARY KEY) ENGINE=Aria;
|
INSERT INTO t2 VALUES (1),(2),(3);
|
CREATE VIEW v2 AS SELECT pk2, COUNT(*) AS cnt FROM t2 GROUP BY pk2;
|
Now when i run this analyze command
MariaDB [test]> ANALYZE FORMAT=JSON SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5;
|
the output is
| {
|
"query_block": {
|
"select_id": 1,
|
"r_loops": 1,
|
"r_total_time_ms": 1.1568,
|
"table": {
|
"table_name": "t1",
|
"access_type": "ALL",
|
"possible_keys": ["PRIMARY"],
|
"r_loops": 1,
|
"rows": 2,
|
"r_rows": 2,
|
"r_total_time_ms": 0.0677,
|
"filtered": 100,
|
"r_filtered": 100,
|
"attached_condition": "t1.f <> 5"
|
},
|
"table": {
|
"table_name": "<derived2>",
|
"access_type": "ref",
|
"possible_keys": ["key0"],
|
"key": "key0",
|
"key_length": "4",
|
"used_key_parts": ["pk2"],
|
"ref": ["test.t1.pk1"],
|
"r_loops": 2,
|
"rows": 2,
|
"r_rows": 1,
|
"r_total_time_ms": 0.7043,
|
"filtered": 100,
|
"r_filtered": 100,
|
"materialized": {
|
"query_block": {
|
"select_id": 2,
|
"r_loops": 2,
|
"r_total_time_ms": 0.8569,
|
"outer_ref_condition": "t1.pk1 is not null",
|
"table": {
|
"table_name": "t2",
|
"access_type": "eq_ref",
|
"possible_keys": ["PRIMARY"],
|
"key": "PRIMARY",
|
"key_length": "4",
|
"used_key_parts": ["pk2"],
|
"ref": ["test.t1.pk1"],
|
"r_loops": 2,
|
"rows": 1,
|
"r_rows": 1,
|
"r_total_time_ms": 0.0723,
|
"filtered": 100,
|
"r_filtered": 100,
|
"using_index": true
|
}
|
}
|
}
|
}
|
}
|
} |
|
So if you look closely at the "outer_ref_condition": "t1.pk1 is not null". But as we see in the create table statement t1.pk1 is a primary key and so it is guaranteed to be NOT NULL so this is a useless condition to have.
{"report":{"fcp":930.2999999523163,"ttfb":293.2999999523163,"pageVisibility":"visible","entityId":67140,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"0671a5d1-536c-4742-9eab-a5d4e86fb1ed","navigationType":0,"readyForUser":1011.8999999761581,"redirectCount":0,"resourceLoadedEnd":660.6999999284744,"resourceLoadedStart":299.2999999523163,"resourceTiming":[{"duration":13.100000023841858,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":299.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":299.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":312.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":13.199999928474426,"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":299.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":299.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":312.6999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":234.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":299.60000002384186,"connectEnd":299.60000002384186,"connectStart":299.60000002384186,"domainLookupEnd":299.60000002384186,"domainLookupStart":299.60000002384186,"fetchStart":299.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":316,"responseEnd":533.8999999761581,"responseStart":349,"secureConnectionStart":299.60000002384186},{"duration":360.89999997615814,"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":299.7999999523163,"connectEnd":299.7999999523163,"connectStart":299.7999999523163,"domainLookupEnd":299.7999999523163,"domainLookupStart":299.7999999523163,"fetchStart":299.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":316.5,"responseEnd":660.6999999284744,"responseStart":368.1999999284744,"secureConnectionStart":299.7999999523163},{"duration":57.699999928474426,"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":300,"connectEnd":300,"connectStart":300,"domainLookupEnd":300,"domainLookupStart":300,"fetchStart":300,"redirectEnd":0,"redirectStart":0,"requestStart":317.10000002384186,"responseEnd":357.6999999284744,"responseStart":350.60000002384186,"secureConnectionStart":300},{"duration":58.800000071525574,"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":300.1999999284744,"connectEnd":300.1999999284744,"connectStart":300.1999999284744,"domainLookupEnd":300.1999999284744,"domainLookupStart":300.1999999284744,"fetchStart":300.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":317.5,"responseEnd":359,"responseStart":352.10000002384186,"secureConnectionStart":300.1999999284744},{"duration":58,"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":300.39999997615814,"connectEnd":300.39999997615814,"connectStart":300.39999997615814,"domainLookupEnd":300.39999997615814,"domainLookupStart":300.39999997615814,"fetchStart":300.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":317.60000002384186,"responseEnd":358.39999997615814,"responseStart":351.39999997615814,"secureConnectionStart":300.39999997615814},{"duration":15.599999904632568,"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":300.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":300.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":316.1999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":59.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":300.7999999523163,"connectEnd":300.7999999523163,"connectStart":300.7999999523163,"domainLookupEnd":300.7999999523163,"domainLookupStart":300.7999999523163,"fetchStart":300.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":319,"responseEnd":360.2999999523163,"responseStart":354,"secureConnectionStart":300.7999999523163},{"duration":16.5,"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":300.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":300.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":317.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":59.699999928474426,"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":301,"connectEnd":301,"connectStart":301,"domainLookupEnd":301,"domainLookupStart":301,"fetchStart":301,"redirectEnd":0,"redirectStart":0,"requestStart":319.89999997615814,"responseEnd":360.6999999284744,"responseStart":355,"secureConnectionStart":301},{"duration":308.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":301.7999999523163,"connectEnd":301.7999999523163,"connectStart":301.7999999523163,"domainLookupEnd":301.7999999523163,"domainLookupStart":301.7999999523163,"fetchStart":301.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":346.6999999284744,"responseEnd":610.2999999523163,"responseStart":603.3999999761581,"secureConnectionStart":301.7999999523163},{"duration":309.60000002384186,"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":301.7999999523163,"connectEnd":301.7999999523163,"connectStart":301.7999999523163,"domainLookupEnd":301.7999999523163,"domainLookupStart":301.7999999523163,"fetchStart":301.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":358,"responseEnd":611.3999999761581,"responseStart":606.1999999284744,"secureConnectionStart":301.7999999523163},{"duration":115.80000007152557,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":659.1999999284744,"connectEnd":659.1999999284744,"connectStart":659.1999999284744,"domainLookupEnd":659.1999999284744,"domainLookupStart":659.1999999284744,"fetchStart":659.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":737.7999999523163,"responseEnd":775,"responseStart":773.8999999761581,"secureConnectionStart":659.1999999284744},{"duration":264.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":888,"connectEnd":888,"connectStart":888,"domainLookupEnd":888,"domainLookupStart":888,"fetchStart":888,"redirectEnd":0,"redirectStart":0,"requestStart":1116.5,"responseEnd":1152.5,"responseStart":1150.5,"secureConnectionStart":888}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":37,"responseStart":293,"responseEnd":298,"domLoading":296,"domInteractive":1106,"domContentLoadedEventStart":1106,"domContentLoadedEventEnd":1148,"domComplete":1508,"loadEventStart":1508,"loadEventEnd":1508,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1052.7999999523163},{"name":"bigPipe.sidebar-id.end","time":1053.6000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":1053.6999999284744},{"name":"bigPipe.activity-panel-pipe-id.end","time":1054.6999999284744},{"name":"activityTabFullyLoaded","time":1163}],"measures":[],"correlationId":"a5bce74f713260","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":117,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Patch
http://lists.askmonty.org/pipermail/commits/2018-April/012473.html