Discovered as part of MDEV-9420. See these comments:
https://mariadb.atlassian.net/browse/MDEV-9420?focusedCommentId=80164&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-80164
https://mariadb.atlassian.net/browse/MDEV-9420?focusedCommentId=80165&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-80165
Copying here:
Checking problem #1.
MariaDB 10.0:
MariaDB [j10]> explain select * from point_activite
|
WHERE `id_activity_list` = 1479 AND `id_contact_Script` = 2075347 AND `id_contact_campaign_pass` = 1920183 \G
|
*************************** 1. row ***************************
|
id: 1
|
select_type: SIMPLE
|
table: point_activite
|
type: index_merge
|
possible_keys: id_contact_Script,id_activity_list,id_contact_campaign_pass
|
key: id_contact_campaign_pass,id_contact_Script
|
key_len: 9,9
|
ref: NULL
|
rows: 1
|
Extra: Using intersect(id_contact_campaign_pass,id_contact_Script); Using where
|
MariaDB [j10]> explain select * from point_activite
|
WHERE `id_activity_list` = 1479 AND `id_contact_Script` = 2075347 AND `id_contact_campaign_pass` = 1920183
|
ORDER BY `IDPoint_Activite`\G
|
*************************** 1. row ***************************
|
id: 1
|
select_type: SIMPLE
|
table: point_activite
|
type: index_merge
|
possible_keys: id_contact_Script,id_activity_list,id_contact_campaign_pass
|
key: id_contact_campaign_pass,id_contact_Script
|
key_len: 9,9
|
ref: NULL
|
rows: 1
|
Extra: Using intersect(id_contact_campaign_pass,id_contact_Script); Using where; Using filesort
|
So, in 10.0, the plan is always to use index_merge to produce one row. Actually, two rows are produced and the query finishes in 0.05 sec or less.
In 10.1.10:
MariaDB [j10]> explain select * from point_activite
|
WHERE `id_activity_list` = 1479 AND `id_contact_Script` = 2075347 AND `id_contact_campaign_pass` = 1920183\G
|
*************************** 1. row ***************************
|
id: 1
|
select_type: SIMPLE
|
table: point_activite
|
type: index_merge
|
possible_keys: id_contact_Script,id_activity_list,id_contact_campaign_pass
|
key: id_contact_campaign_pass,id_contact_Script
|
key_len: 9,9
|
ref: NULL
|
rows: 1
|
Extra: Using intersect(id_contact_campaign_pass,id_contact_Script); Using where
|
The same so far. Adding ORDER BY:
explain select * from point_activite
|
WHERE `id_activity_list` = 1479 AND `id_contact_Script` = 2075347 AND `id_contact_campaign_pass` = 1920183
|
ORDER BY `IDPoint_Activite`\G
|
*************************** 1. row ***************************
|
id: 1
|
select_type: SIMPLE
|
table: point_activite
|
type: index
|
possible_keys: id_contact_Script,id_activity_list,id_contact_campaign_pass
|
key: PRIMARY
|
key_len: 8
|
ref: NULL
|
rows: 1997722
|
Extra: Using where
|
And the plan becomes much worse. It wants to read nearly 2M rows. Execution takes 1 min 39 sec.
{"report":{"fcp":1050.3000001907349,"ttfb":180.39999961853027,"pageVisibility":"visible","entityId":55337,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"86ade9f6-ed76-4ff6-b904-b38a369b9f90","navigationType":0,"readyForUser":1129,"redirectCount":0,"resourceLoadedEnd":813.1999998092651,"resourceLoadedStart":195.80000019073486,"resourceTiming":[{"duration":393.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":195.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":589.5,"responseStart":0,"secureConnectionStart":0},{"duration":393.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":196,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":589.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":403.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":196.19999980926514,"connectEnd":196.19999980926514,"connectStart":196.19999980926514,"domainLookupEnd":196.19999980926514,"domainLookupStart":196.19999980926514,"fetchStart":196.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":196.19999980926514,"responseEnd":599.5,"responseStart":599.5,"secureConnectionStart":196.19999980926514},{"duration":429.20000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":196.39999961853027,"connectEnd":196.39999961853027,"connectStart":196.39999961853027,"domainLookupEnd":196.39999961853027,"domainLookupStart":196.39999961853027,"fetchStart":196.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":196.39999961853027,"responseEnd":625.6000003814697,"responseStart":625.6000003814697,"secureConnectionStart":196.39999961853027},{"duration":433.1000003814697,"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":196.69999980926514,"connectEnd":196.69999980926514,"connectStart":196.69999980926514,"domainLookupEnd":196.69999980926514,"domainLookupStart":196.69999980926514,"fetchStart":196.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":196.69999980926514,"responseEnd":629.8000001907349,"responseStart":629.8000001907349,"secureConnectionStart":196.69999980926514},{"duration":433.5,"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":196.80000019073486,"connectEnd":196.80000019073486,"connectStart":196.80000019073486,"domainLookupEnd":196.80000019073486,"domainLookupStart":196.80000019073486,"fetchStart":196.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":196.80000019073486,"responseEnd":630.3000001907349,"responseStart":630.3000001907349,"secureConnectionStart":196.80000019073486},{"duration":433.69999980926514,"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":197,"connectEnd":197,"connectStart":197,"domainLookupEnd":197,"domainLookupStart":197,"fetchStart":197,"redirectEnd":0,"redirectStart":0,"requestStart":197,"responseEnd":630.6999998092651,"responseStart":630.6999998092651,"secureConnectionStart":197},{"duration":435.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":197.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":197.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":632.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":433.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":197.39999961853027,"connectEnd":197.39999961853027,"connectStart":197.39999961853027,"domainLookupEnd":197.39999961853027,"domainLookupStart":197.39999961853027,"fetchStart":197.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":197.39999961853027,"responseEnd":631.1999998092651,"responseStart":631.1999998092651,"secureConnectionStart":197.39999961853027},{"duration":435.1000003814697,"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":197.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":197.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":632.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":434.1000003814697,"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":197.69999980926514,"connectEnd":197.69999980926514,"connectStart":197.69999980926514,"domainLookupEnd":197.69999980926514,"domainLookupStart":197.69999980926514,"fetchStart":197.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":197.69999980926514,"responseEnd":631.8000001907349,"responseStart":631.8000001907349,"secureConnectionStart":197.69999980926514},{"duration":459.0999994277954,"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":198.60000038146973,"connectEnd":198.60000038146973,"connectStart":198.60000038146973,"domainLookupEnd":198.60000038146973,"domainLookupStart":198.60000038146973,"fetchStart":198.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":198.60000038146973,"responseEnd":657.6999998092651,"responseStart":657.6999998092651,"secureConnectionStart":198.60000038146973},{"duration":614.5999994277954,"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":198.60000038146973,"connectEnd":198.60000038146973,"connectStart":198.60000038146973,"domainLookupEnd":198.60000038146973,"domainLookupStart":198.60000038146973,"fetchStart":198.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":198.60000038146973,"responseEnd":813.1999998092651,"responseStart":813.1999998092651,"secureConnectionStart":198.60000038146973}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":15,"responseStart":180,"responseEnd":182,"domLoading":193,"domInteractive":1189,"domContentLoadedEventStart":1189,"domContentLoadedEventEnd":1239,"domComplete":2529,"loadEventStart":2530,"loadEventEnd":2531,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1169.8000001907349},{"name":"bigPipe.sidebar-id.end","time":1170.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1170.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1173.3000001907349},{"name":"activityTabFullyLoaded","time":1246.3999996185303}],"measures":[],"correlationId":"8261a338487146","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":94,"dbReadsTimeInMs":10,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}