Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
10.3.1 , 11.1.1 , 10.4(EOL) , 10.5 , 10.6 , 10.9(EOL) , 10.10(EOL) , 10.11 , 11.0(EOL) , 11.1(EOL)
Environment:
Docker Hub's official MariaDB image
When lateral derived optimization is applied to a join using <=> , NULL values are not joined as expected. This issue seems to have been present since MariaDB 10.3.1 when the lateral derived optimization was introduced.
How to reproduce:
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE test1 (
num1 INT NULL,
KEY (num1)
);
INSERT INTO test1 VALUES (NULL), (1);
CREATE TABLE test2 (
num2 INT NULL,
KEY (num2)
);
INSERT INTO test2 VALUES (NULL), (2);
-- Set split_materialized to off to receive correct results
SET optimizer_switch='split_materialized=on';
WITH test AS (
SELECT num1
FROM test1
GROUP BY num1
)
SELECT test.num1, test2.num2
FROM test2
-- Both test and test2 have a NULL value, so this join should return one row.
INNER JOIN test ON test.num1 <=> test2.num2
-- test2.num2 is NULL for the only expected row, but this condition is here to
-- make the optimizer use lateral derived optimization. Removing this condition
-- causes the query to return correct results.
WHERE test2.num2 IS NULL;
Expected results (returned when running with split_materialized=off or after removing the WHERE ):
+------+------+
| num1 | num2 |
+------+------+
| NULL | NULL |
+------+------+
1 row in set
Actual results:
Empty set
EXPLAIN output for the query with split_materialized enabled:
+------+-----------------+------------+------+---------------+------+---------+-------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-----------------+------------+------+---------------+------+---------+-------------------+------+--------------------------+
| 1 | PRIMARY | test2 | ref | num2 | num2 | 5 | const | 1 | Using where; Using index |
| 1 | PRIMARY | <derived2> | ref | key0 | key0 | 5 | testdb.test2.num2 | 1 | Using where |
| 2 | LATERAL DERIVED | test1 | ref | num1 | num1 | 5 | testdb.test2.num2 | 1 | Using index |
+------+-----------------+------------+------+---------------+------+---------+-------------------+------+--------------------------+
{"report":{"fcp":851.7999999523163,"ttfb":157.20000004768372,"pageVisibility":"visible","entityId":123925,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"8fd10bae-f681-4bf1-ba64-b433c67543e5","navigationType":0,"readyForUser":983.2000000476837,"redirectCount":0,"resourceLoadedEnd":940.5,"resourceLoadedStart":177.90000009536743,"resourceTiming":[{"duration":214.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":177.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":177.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":392.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":214.79999995231628,"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":178,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":178,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":392.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":230.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":178.20000004768372,"connectEnd":178.20000004768372,"connectStart":178.20000004768372,"domainLookupEnd":178.20000004768372,"domainLookupStart":178.20000004768372,"fetchStart":178.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":178.20000004768372,"responseEnd":408.5,"responseStart":408.5,"secureConnectionStart":178.20000004768372},{"duration":356.2000000476837,"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":178.29999995231628,"connectEnd":178.29999995231628,"connectStart":178.29999995231628,"domainLookupEnd":178.29999995231628,"domainLookupStart":178.29999995231628,"fetchStart":178.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":178.29999995231628,"responseEnd":534.5,"responseStart":534.5,"secureConnectionStart":178.29999995231628},{"duration":360.59999990463257,"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":178.40000009536743,"connectEnd":178.40000009536743,"connectStart":178.40000009536743,"domainLookupEnd":178.40000009536743,"domainLookupStart":178.40000009536743,"fetchStart":178.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":178.40000009536743,"responseEnd":539,"responseStart":539,"secureConnectionStart":178.40000009536743},{"duration":361.19999980926514,"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":178.40000009536743,"connectEnd":178.40000009536743,"connectStart":178.40000009536743,"domainLookupEnd":178.40000009536743,"domainLookupStart":178.40000009536743,"fetchStart":178.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":178.40000009536743,"responseEnd":539.5999999046326,"responseStart":539.5,"secureConnectionStart":178.40000009536743},{"duration":362,"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":178.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":178.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":540.5,"responseStart":0,"secureConnectionStart":0},{"duration":361.5,"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":178.5,"connectEnd":178.5,"connectStart":178.5,"domainLookupEnd":178.5,"domainLookupStart":178.5,"fetchStart":178.5,"redirectEnd":0,"redirectStart":0,"requestStart":178.5,"responseEnd":540,"responseStart":540,"secureConnectionStart":178.5},{"duration":361.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":178.70000004768372,"connectEnd":178.70000004768372,"connectStart":178.70000004768372,"domainLookupEnd":178.70000004768372,"domainLookupStart":178.70000004768372,"fetchStart":178.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":178.70000004768372,"responseEnd":540.5999999046326,"responseStart":540.5999999046326,"secureConnectionStart":178.70000004768372},{"duration":362.19999980926514,"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":178.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":178.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":541.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":362.2999999523163,"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":178.90000009536743,"connectEnd":178.90000009536743,"connectStart":178.90000009536743,"domainLookupEnd":178.90000009536743,"domainLookupStart":178.90000009536743,"fetchStart":178.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":178.90000009536743,"responseEnd":541.2000000476837,"responseStart":541.2000000476837,"secureConnectionStart":178.90000009536743},{"duration":760.0999999046326,"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":179.70000004768372,"connectEnd":179.70000004768372,"connectStart":179.70000004768372,"domainLookupEnd":179.70000004768372,"domainLookupStart":179.70000004768372,"fetchStart":179.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":179.70000004768372,"responseEnd":939.7999999523163,"responseStart":939.7999999523163,"secureConnectionStart":179.70000004768372},{"duration":760.7000000476837,"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":179.79999995231628,"connectEnd":179.79999995231628,"connectStart":179.79999995231628,"domainLookupEnd":179.79999995231628,"domainLookupStart":179.79999995231628,"fetchStart":179.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":179.79999995231628,"responseEnd":940.5,"responseStart":940.5,"secureConnectionStart":179.79999995231628},{"duration":28.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":613,"connectEnd":613,"connectStart":613,"domainLookupEnd":613,"domainLookupStart":613,"fetchStart":613,"redirectEnd":0,"redirectStart":0,"requestStart":613,"responseEnd":641.5,"responseStart":641.5,"secureConnectionStart":613},{"duration":100.70000004768372,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":845.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":845.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":946,"responseStart":0,"secureConnectionStart":0},{"duration":201.59999990463257,"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":866.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":866.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1068.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":201.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":866.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":866.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1068.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":201,"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":867.7000000476837,"connectEnd":867.7000000476837,"connectStart":867.7000000476837,"domainLookupEnd":867.7000000476837,"domainLookupStart":867.7000000476837,"fetchStart":867.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":867.7000000476837,"responseEnd":1068.7000000476837,"responseStart":1068.7000000476837,"secureConnectionStart":867.7000000476837},{"duration":205.20000004768372,"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":868.0999999046326,"connectEnd":868.0999999046326,"connectStart":868.0999999046326,"domainLookupEnd":868.0999999046326,"domainLookupStart":868.0999999046326,"fetchStart":868.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":868.0999999046326,"responseEnd":1073.2999999523163,"responseStart":1073.2999999523163,"secureConnectionStart":868.0999999046326},{"duration":206.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":868.5,"connectEnd":868.5,"connectStart":868.5,"domainLookupEnd":868.5,"domainLookupStart":868.5,"fetchStart":868.5,"redirectEnd":0,"redirectStart":0,"requestStart":868.5,"responseEnd":1074.7999999523163,"responseStart":1074.7999999523163,"secureConnectionStart":868.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":30,"responseStart":157,"responseEnd":171,"domLoading":175,"domInteractive":1040,"domContentLoadedEventStart":1040,"domContentLoadedEventEnd":1083,"domComplete":1684,"loadEventStart":1684,"loadEventEnd":1686,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1022.2000000476837},{"name":"bigPipe.sidebar-id.end","time":1022.7999999523163},{"name":"bigPipe.activity-panel-pipe-id.start","time":1023},{"name":"bigPipe.activity-panel-pipe-id.end","time":1025.4000000953674},{"name":"activityTabFullyLoaded","time":1091.4000000953674}],"measures":[],"correlationId":"a1dc7cf316c7ca","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":70,"dbReadsTimeInMs":9,"dbConnsTimeInMs":16,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}