MDEV-15253 inbtriduced a change in MariaDB 10.4. Now by default optimizer_use_condition_selectivity=4 instead of 1. As a result we may get bad plans after upgrade to 10.4. For example, in 10.4 we get:
1 SIMPLE ticketgrou0_ range PRIMARY,index_ticket_group_on_business_id_and_date... index_ticket_group_on_business_id_and_is_archived_... 10 1770 1770.00 0.00 100.00 Using where; Using index
|
1 SIMPLE tables0_ ref index_ticket_group_table_on_table_id,index_ticket_... index_ticket_group_table_on_tg_id 4 tock_staging.ticketgrou0_.id 1 1.24 100.00 100.00 Using where; Using index
|
1 SIMPLE tableentit1_ ALL PRIMARY 66037 66280.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
Same query on MariaDB 10.3:
1 PRIMARY ticketgrou0_ range PRIMARY,index_ticket_group_on_business_id_and_date... index_ticket_group_on_business_id_and_is_archived_... 10 1770 1770.00 100.00 100.00 Using where; Using index
|
1 PRIMARY tables0_ ref index_ticket_group_table_on_tg_id,index_ticket_gro... index_ticket_group_table_on_tg_id 4 tock_prod.ticketgrou0_.id 1 1.24 100.00 100.00 Using index condition
|
1 PRIMARY tableentit1_ eq_ref PRIMARY PRIMARY 4 tock_prod.tables0_.table_id 1 1.00 100.00 100.00 Using where
|
Note that instead of eq_ref access by primary key we get full table scan and BNL join, that in practice end up as a very serious performance regression.
Setting optimizer_use_condition_selectivity=1 allows to get the same better plan as in 10.3.
- relates to
-
MDEV-21377
Eq_ref access not picked by query with optimizer_use_condition_selectivity > 1
-
-
Closed
{"report":{"fcp":1460.5999999046326,"ttfb":555.2999999523163,"pageVisibility":"visible","entityId":78526,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"b2cc0fe8-9c00-41a8-8c04-2b2defcde69e","navigationType":0,"readyForUser":1535.8999998569489,"redirectCount":0,"resourceLoadedEnd":1174.0999999046326,"resourceLoadedStart":563.5,"resourceTiming":[{"duration":126.79999995231628,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":563.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":563.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":690.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":126.90000009536743,"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":563.8999998569489,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":563.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":690.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":479.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":564,"connectEnd":564,"connectStart":564,"domainLookupEnd":564,"domainLookupStart":564,"fetchStart":564,"redirectEnd":0,"redirectStart":0,"requestStart":697.3999998569489,"responseEnd":1043.8999998569489,"responseStart":741.0999999046326,"secureConnectionStart":564},{"duration":610,"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":564.0999999046326,"connectEnd":564.0999999046326,"connectStart":564.0999999046326,"domainLookupEnd":564.0999999046326,"domainLookupStart":564.0999999046326,"fetchStart":564.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":698.0999999046326,"responseEnd":1174.0999999046326,"responseStart":819.7999999523163,"secureConnectionStart":564.0999999046326},{"duration":205.29999995231628,"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":564.2999999523163,"connectEnd":564.2999999523163,"connectStart":564.2999999523163,"domainLookupEnd":564.2999999523163,"domainLookupStart":564.2999999523163,"fetchStart":564.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":701.7999999523163,"responseEnd":769.5999999046326,"responseStart":765.0999999046326,"secureConnectionStart":564.2999999523163},{"duration":205.70000004768372,"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":564.3999998569489,"connectEnd":564.3999998569489,"connectStart":564.3999998569489,"domainLookupEnd":564.3999998569489,"domainLookupStart":564.3999998569489,"fetchStart":564.3999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":702.7000000476837,"responseEnd":770.0999999046326,"responseStart":765.7999999523163,"secureConnectionStart":564.3999998569489},{"duration":205.79999995231628,"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":564.5,"connectEnd":564.5,"connectStart":564.5,"domainLookupEnd":564.5,"domainLookupStart":564.5,"fetchStart":564.5,"redirectEnd":0,"redirectStart":0,"requestStart":703,"responseEnd":770.2999999523163,"responseStart":766.5999999046326,"secureConnectionStart":564.5},{"duration":132.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":564.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":564.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":697.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":205.89999985694885,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":564.7000000476837,"connectEnd":564.7000000476837,"connectStart":564.7000000476837,"domainLookupEnd":564.7000000476837,"domainLookupStart":564.7000000476837,"fetchStart":564.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":704,"responseEnd":770.5999999046326,"responseStart":767.3999998569489,"secureConnectionStart":564.7000000476837},{"duration":132.90000009536743,"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":564.8999998569489,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":564.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":697.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":206,"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":565.0999999046326,"connectEnd":565.0999999046326,"connectStart":565.0999999046326,"domainLookupEnd":565.0999999046326,"domainLookupStart":565.0999999046326,"fetchStart":565.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":704.2000000476837,"responseEnd":771.0999999046326,"responseStart":768.2999999523163,"secureConnectionStart":565.0999999046326},{"duration":591.3000001907349,"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":573.8999998569489,"connectEnd":573.8999998569489,"connectStart":573.8999998569489,"domainLookupEnd":573.8999998569489,"domainLookupStart":573.8999998569489,"fetchStart":573.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":834.8999998569489,"responseEnd":1165.2000000476837,"responseStart":1155.2000000476837,"secureConnectionStart":573.8999998569489},{"duration":569.8000001907349,"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":596.8999998569489,"connectEnd":596.8999998569489,"connectStart":596.8999998569489,"domainLookupEnd":596.8999998569489,"domainLookupStart":596.8999998569489,"fetchStart":596.8999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":949.5999999046326,"responseEnd":1166.7000000476837,"responseStart":1164.5,"secureConnectionStart":596.8999998569489},{"duration":198.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1180.0999999046326,"connectEnd":1180.0999999046326,"connectStart":1180.0999999046326,"domainLookupEnd":1180.0999999046326,"domainLookupStart":1180.0999999046326,"fetchStart":1180.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1345.8999998569489,"responseEnd":1379,"responseStart":1378.3999998569489,"secureConnectionStart":1180.0999999046326},{"duration":219.09999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1414.5,"connectEnd":1414.5,"connectStart":1414.5,"domainLookupEnd":1414.5,"domainLookupStart":1414.5,"fetchStart":1414.5,"redirectEnd":0,"redirectStart":0,"requestStart":1597.2999999523163,"responseEnd":1633.5999999046326,"responseStart":1632.5,"secureConnectionStart":1414.5},{"duration":145.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1452.5999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1452.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1598.0999999046326,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":351,"domainLookupEnd":365,"connectStart":365,"connectEnd":386,"secureConnectionStart":374,"requestStart":386,"responseStart":556,"responseEnd":597,"domLoading":559,"domInteractive":1651,"domContentLoadedEventStart":1651,"domContentLoadedEventEnd":1711,"domComplete":2178,"loadEventStart":2178,"loadEventEnd":2178,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1611.2000000476837},{"name":"bigPipe.sidebar-id.end","time":1612},{"name":"bigPipe.activity-panel-pipe-id.start","time":1612.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":1616.3999998569489},{"name":"activityTabFullyLoaded","time":1727.7000000476837}],"measures":[],"correlationId":"7d606e32e1cb53","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":81,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Making EXPLAINs a bit more readable.
MariaDB 10.4:
table type key rows r_rows filtered r_filtered
1 SIMPLE ticketgrou0_ range index_ticket_group_on_business_id... 1770 1770.00 0.00 100.00 Using where; Using index
1 SIMPLE tables0_ ref index_ticket_group_table_on_tg_id 1 1.24 100.00 100.00 Using where; Using index
1 SIMPLE tableentit1_ ALL NULL 66037 66280.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
Same query on MariaDB 10.3:
table type key rows r_rows filtered r_filtered
1 PRIMARY ticketgrou0_ range index_ticket_group_on_business_id... 1770 1770.00 100.00 100.00 Using where; Using index
1 PRIMARY tables0_ ref index_ticket_group_table_on_tg_id 1 1.24 100.00 100.00 Using index condition
1 PRIMARY tableentit1_ eq_ref PRIMARY 1 1.00 100.00 100.00 Using where
Note that "filtered" is 100% here (so why does optimizer_use_condition_selectivity play a role)?
The incoming fanout into the 3rd table is 1.7K rows... and then: