Type:
Task
Priority:
Minor
Resolution:
Unresolved
Fix Version/s:
None
When optimizer considers different indexes for a query, for every index it needs to know
what columns are part of the index
the index cardinality
records_in_range — number of values within a specific constant range
Note that the first question doesn't need the index to be created. And the other two can be answered from EITS, so they don't need an index either.
So, the optimizer should, technically, be able to create an execution plan that uses an index, even if the index does not exist! This could be incorporated into a new explain mode, say EXPLAIN SUGGEST_INDEXES that will return what indexes (if created) would reduce the query execution cost and how.
Sergei Golubchik
made changes -
2018-11-25 12:46
Field
Original Value
New Value
Description
When optimizer considers different indexes for a query, for every index it needs to know
* what columns are part of the index
* the index cardinality
* records_in_range — number of values within a specific constant range
Note that the first question doesn't need the index to be created. And the other two can be answered from EITS, so they don't need an index either.
So, the optimizer should, technically, be able to create an execution plan that uses an index, that does not exist! This could be incorporated into a new explain mode, say {{EXPLAIN SUGGEST_INDEXES}} that will return what indexes (if created) would reduce the query execution cost and how.
When optimizer considers different indexes for a query, for every index it needs to know
* what columns are part of the index
* the index cardinality
* records_in_range — number of values within a specific constant range
Note that the first question doesn't need the index to be created. And the other two can be answered from EITS, so they don't need an index either.
So, the optimizer should, technically, be able to create an execution plan that uses an index, even if the index does not exist! This could be incorporated into a new explain mode, say {{EXPLAIN SUGGEST_INDEXES}} that will return what indexes (if created) would reduce the query execution cost and how.
Sergei Golubchik
made changes -
2021-12-06 21:21
Workflow
MariaDB v3
[ 90863
]
MariaDB v4
[ 130945
]
{"report":{"fcp":880.2999999523163,"ttfb":181.89999997615814,"pageVisibility":"visible","entityId":71041,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"d3bf6b9e-d6be-43ea-8a58-bb06abedad16","navigationType":0,"readyForUser":948,"redirectCount":0,"resourceLoadedEnd":994.2000000476837,"resourceLoadedStart":190.29999995231628,"resourceTiming":[{"duration":177.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":190.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":190.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":367.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":177.69999992847443,"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":190.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":190.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":368.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":190.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":190.79999995231628,"connectEnd":190.79999995231628,"connectStart":190.79999995231628,"domainLookupEnd":190.79999995231628,"domainLookupStart":190.79999995231628,"fetchStart":190.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":190.79999995231628,"responseEnd":381.5,"responseStart":381.5,"secureConnectionStart":190.79999995231628},{"duration":278.5,"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":191.5,"connectEnd":191.5,"connectStart":191.5,"domainLookupEnd":191.5,"domainLookupStart":191.5,"fetchStart":191.5,"redirectEnd":0,"redirectStart":0,"requestStart":191.5,"responseEnd":470,"responseStart":470,"secureConnectionStart":191.5},{"duration":282.1999999284744,"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":191.60000002384186,"connectEnd":191.60000002384186,"connectStart":191.60000002384186,"domainLookupEnd":191.60000002384186,"domainLookupStart":191.60000002384186,"fetchStart":191.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":191.60000002384186,"responseEnd":473.7999999523163,"responseStart":473.7999999523163,"secureConnectionStart":191.60000002384186},{"duration":326.7000000476837,"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":191.79999995231628,"connectEnd":191.79999995231628,"connectStart":191.79999995231628,"domainLookupEnd":191.79999995231628,"domainLookupStart":191.79999995231628,"fetchStart":191.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":191.79999995231628,"responseEnd":518.5,"responseStart":518.5,"secureConnectionStart":191.79999995231628},{"duration":327,"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":191.89999997615814,"connectEnd":191.89999997615814,"connectStart":191.89999997615814,"domainLookupEnd":191.89999997615814,"domainLookupStart":191.89999997615814,"fetchStart":191.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":191.89999997615814,"responseEnd":518.8999999761581,"responseStart":518.8999999761581,"secureConnectionStart":191.89999997615814},{"duration":332,"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":192.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":192.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":524.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":329.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":192.29999995231628,"connectEnd":192.29999995231628,"connectStart":192.29999995231628,"domainLookupEnd":192.29999995231628,"domainLookupStart":192.29999995231628,"fetchStart":192.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":192.29999995231628,"responseEnd":521.3999999761581,"responseStart":521.3999999761581,"secureConnectionStart":192.29999995231628},{"duration":331.7999999523163,"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":192.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":192.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":524.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":329.59999990463257,"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":192.70000004768372,"connectEnd":192.70000004768372,"connectStart":192.70000004768372,"domainLookupEnd":192.70000004768372,"domainLookupStart":192.70000004768372,"fetchStart":192.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":192.70000004768372,"responseEnd":522.2999999523163,"responseStart":522.2999999523163,"secureConnectionStart":192.70000004768372},{"duration":795.1000000238419,"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":198.10000002384186,"connectEnd":198.10000002384186,"connectStart":198.10000002384186,"domainLookupEnd":198.10000002384186,"domainLookupStart":198.10000002384186,"fetchStart":198.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":198.10000002384186,"responseEnd":993.2000000476837,"responseStart":993.2000000476837,"secureConnectionStart":198.10000002384186},{"duration":791,"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":203.20000004768372,"connectEnd":203.20000004768372,"connectStart":203.20000004768372,"domainLookupEnd":203.20000004768372,"domainLookupStart":203.20000004768372,"fetchStart":203.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":203.20000004768372,"responseEnd":994.2000000476837,"responseStart":994.2000000476837,"secureConnectionStart":203.20000004768372},{"duration":66.10000002384186,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":534.8999999761581,"connectEnd":534.8999999761581,"connectStart":534.8999999761581,"domainLookupEnd":534.8999999761581,"domainLookupStart":534.8999999761581,"fetchStart":534.8999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":534.8999999761581,"responseEnd":601,"responseStart":601,"secureConnectionStart":534.8999999761581},{"duration":275.10000002384186,"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":797.6000000238419,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":797.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1072.7000000476837,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":10,"responseStart":181,"responseEnd":203,"domLoading":185,"domInteractive":1027,"domContentLoadedEventStart":1027,"domContentLoadedEventEnd":1072,"domComplete":1277,"loadEventStart":1277,"loadEventEnd":1278,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":997.7999999523163},{"name":"bigPipe.sidebar-id.end","time":998.6000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":998.7999999523163},{"name":"bigPipe.activity-panel-pipe-id.end","time":1001.8999999761581},{"name":"activityTabFullyLoaded","time":1089.2999999523163}],"measures":[],"correlationId":"6fcc68bff47a24","effectiveType":"4g","downlink":9.6,"rtt":0,"serverDuration":112,"dbReadsTimeInMs":17,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
I have a prototype; it takes only a SELECT and generates suggestions for each table in a JOIN.
With more information, it could
(and other things).