Type:
Task
Priority:
Major
Resolution:
Fixed
Description
best_access_path() function has record_count parameter which specifies how many times the access method will be invoked.
However for eq_ref access, best_access_path() calls prev_record_reads() to determine the "effective" number of eq_ref accesses that will be done.
The return value of prev_record_reads() can be very different from record_count (much less), so this can have a dramatic effect on the query plan choice.
Historically, the code in prev_record_reads() seems to have tried to account for two effects:
eq_ref lookup cache (as described below)
A guess that it is cheaper when one makes lookup with a few repeating key values (as opposed to hitting totally different key values each time)
but the implementation was incorrect for either/both.
(One can observe that these two are not orthogonal. If one can take advantage of eq_ref lookup cache, this means we will not hit a totally different value each time)
What is fixed
This MDEV is about making prev_record_reads() to:
Correctly account for eq_ref lookup cache use.
Otherwise, do not try to take into account that we might be reading the same values over and over.
The rationale for for #2 is that we assume most key reads come from OS/disk cache. In this case, reading the same value multiple times has nearly the same speed as reading a different value each time.
Eq_ref lookup cache
Check the code in join_read_key2().
See the call to cmp_buffer_with_ref().
The logic here is that "if we're about to make a key lookup using the same value as the last time, skip the lookup".
{"report":{"fcp":657.0999999046326,"ttfb":122.79999995231628,"pageVisibility":"visible","entityId":119571,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"da821a79-95d6-4787-8013-ea0906a4371a","navigationType":0,"readyForUser":720,"redirectCount":0,"resourceLoadedEnd":732.4000000953674,"resourceLoadedStart":128.70000004768372,"resourceTiming":[{"duration":22.899999856948853,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":128.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":128.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":151.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":23.09999990463257,"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":128.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":128.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":152,"responseStart":0,"secureConnectionStart":0},{"duration":79.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":129,"connectEnd":129,"connectStart":129,"domainLookupEnd":129,"domainLookupStart":129,"fetchStart":129,"redirectEnd":0,"redirectStart":0,"requestStart":129,"responseEnd":208.90000009536743,"responseStart":208.90000009536743,"secureConnectionStart":129},{"duration":171.20000004768372,"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":129.09999990463257,"connectEnd":129.09999990463257,"connectStart":129.09999990463257,"domainLookupEnd":129.09999990463257,"domainLookupStart":129.09999990463257,"fetchStart":129.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":129.09999990463257,"responseEnd":300.2999999523163,"responseStart":300.2999999523163,"secureConnectionStart":129.09999990463257},{"duration":174.5,"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":129.29999995231628,"connectEnd":129.29999995231628,"connectStart":129.29999995231628,"domainLookupEnd":129.29999995231628,"domainLookupStart":129.29999995231628,"fetchStart":129.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":129.29999995231628,"responseEnd":303.7999999523163,"responseStart":303.7999999523163,"secureConnectionStart":129.29999995231628},{"duration":174.90000009536743,"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":129.29999995231628,"connectEnd":129.29999995231628,"connectStart":129.29999995231628,"domainLookupEnd":129.29999995231628,"domainLookupStart":129.29999995231628,"fetchStart":129.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":129.29999995231628,"responseEnd":304.2000000476837,"responseStart":304.2000000476837,"secureConnectionStart":129.29999995231628},{"duration":175.19999980926514,"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":129.40000009536743,"connectEnd":129.40000009536743,"connectStart":129.40000009536743,"domainLookupEnd":129.40000009536743,"domainLookupStart":129.40000009536743,"fetchStart":129.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":129.40000009536743,"responseEnd":304.59999990463257,"responseStart":304.59999990463257,"secureConnectionStart":129.40000009536743},{"duration":175.5,"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":129.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":129.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":305,"responseStart":0,"secureConnectionStart":0},{"duration":175.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":129.70000004768372,"connectEnd":129.70000004768372,"connectStart":129.70000004768372,"domainLookupEnd":129.70000004768372,"domainLookupStart":129.70000004768372,"fetchStart":129.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":129.70000004768372,"responseEnd":305,"responseStart":305,"secureConnectionStart":129.70000004768372},{"duration":175.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":129.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":129.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":305.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":175.5,"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":130,"connectEnd":130,"connectStart":130,"domainLookupEnd":130,"domainLookupStart":130,"fetchStart":130,"redirectEnd":0,"redirectStart":0,"requestStart":130,"responseEnd":305.5,"responseStart":305.5,"secureConnectionStart":130},{"duration":601.2000000476837,"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":130.5,"connectEnd":130.5,"connectStart":130.5,"domainLookupEnd":130.5,"domainLookupStart":130.5,"fetchStart":130.5,"redirectEnd":0,"redirectStart":0,"requestStart":130.5,"responseEnd":731.7000000476837,"responseStart":731.7000000476837,"secureConnectionStart":130.5},{"duration":601.4000000953674,"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":130.59999990463257,"connectEnd":130.59999990463257,"connectStart":130.59999990463257,"domainLookupEnd":130.59999990463257,"domainLookupStart":130.59999990463257,"fetchStart":130.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":130.59999990463257,"responseEnd":732,"responseStart":732,"secureConnectionStart":130.59999990463257},{"duration":136.79999995231628,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":359.2000000476837,"connectEnd":359.2000000476837,"connectStart":359.2000000476837,"domainLookupEnd":359.2000000476837,"domainLookupStart":359.2000000476837,"fetchStart":359.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":359.2000000476837,"responseEnd":496,"responseStart":496,"secureConnectionStart":359.2000000476837},{"duration":167.20000004768372,"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":565.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":565.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":732.4000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":15,"responseStart":122,"responseEnd":124,"domLoading":126,"domInteractive":764,"domContentLoadedEventStart":764,"domContentLoadedEventEnd":799,"domComplete":1456,"loadEventStart":1456,"loadEventEnd":1458,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":747.2000000476837},{"name":"bigPipe.sidebar-id.end","time":748},{"name":"bigPipe.activity-panel-pipe-id.start","time":748.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":750.5},{"name":"activityTabFullyLoaded","time":806.2999999523163}],"measures":[],"correlationId":"43e8e53d3f26e4","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":61,"dbReadsTimeInMs":9,"dbConnsTimeInMs":15,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}