This is from the same customer issue as MDEV-21243.
It is possible to construct a join query which will use full table scan for one of the tables, even if there is a possible range access for that table.
I'm not sure if table definitions are public so I will not post the details in public until we've figured a general case to demonstrate the issue.
The issue is reproducible on 10.3.{10,20} and 5.5.65. Not reproducible on 5.2.14
Symptoms:
The first range optimizer call constructs the range access.
The problem shows up here in make_join_select
/*
|
We plan to scan all rows.
|
Check again if we should use an index.
|
We could have used an column from a previous table in
|
the index if we are using limit and this is the first table
|
|
(1) - Don't switch the used index if we are using semi-join
|
LooseScan on this table. Using different index will not
|
produce the desired ordering and de-duplication.
|
*/
|
|
if (!tab->table->is_filled_at_execution() &&
|
!tab->loosescan_match_tab && // (1)
|
((cond && (!tab->keys.is_subset(tab->const_keys) && i > 0)) ||
|
(!tab->const_keys.is_clear_all() && i == join->const_tables &&
|
join->unit->select_limit_cnt <
|
join->best_positions[i].records_read &&
|
!(join->select_options & OPTION_FOUND_ROWS))))
|
The if-branch is taken, inside it, SQL_SELECT::test_quick_select is called which doesn't construct the range access anymore (can't use multiple equalities?) and this is how we end up with a full table scan.
{"report":{"fcp":809.7999999523163,"ttfb":144.59999990463257,"pageVisibility":"visible","entityId":81937,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"c32cba9e-f807-485d-8fd0-e0780212c00a","navigationType":0,"readyForUser":884.8999998569489,"redirectCount":0,"resourceLoadedEnd":861.8999998569489,"resourceLoadedStart":154.5,"resourceTiming":[{"duration":160.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":154.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":154.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":314.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":160,"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":154.79999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":154.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":314.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":169.60000014305115,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":154.89999985694885,"connectEnd":154.89999985694885,"connectStart":154.89999985694885,"domainLookupEnd":154.89999985694885,"domainLookupStart":154.89999985694885,"fetchStart":154.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":154.89999985694885,"responseEnd":324.5,"responseStart":324.39999985694885,"secureConnectionStart":154.89999985694885},{"duration":294.19999980926514,"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":155,"connectEnd":155,"connectStart":155,"domainLookupEnd":155,"domainLookupStart":155,"fetchStart":155,"redirectEnd":0,"redirectStart":0,"requestStart":155,"responseEnd":449.19999980926514,"responseStart":449.19999980926514,"secureConnectionStart":155},{"duration":297.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":155.09999990463257,"connectEnd":155.09999990463257,"connectStart":155.09999990463257,"domainLookupEnd":155.09999990463257,"domainLookupStart":155.09999990463257,"fetchStart":155.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":155.09999990463257,"responseEnd":452.69999980926514,"responseStart":452.69999980926514,"secureConnectionStart":155.09999990463257},{"duration":298.40000009536743,"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":155.19999980926514,"connectEnd":155.19999980926514,"connectStart":155.19999980926514,"domainLookupEnd":155.19999980926514,"domainLookupStart":155.19999980926514,"fetchStart":155.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":155.19999980926514,"responseEnd":453.59999990463257,"responseStart":453.59999990463257,"secureConnectionStart":155.19999980926514},{"duration":298.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":155.39999985694885,"connectEnd":155.39999985694885,"connectStart":155.39999985694885,"domainLookupEnd":155.39999985694885,"domainLookupStart":155.39999985694885,"fetchStart":155.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":155.39999985694885,"responseEnd":453.89999985694885,"responseStart":453.89999985694885,"secureConnectionStart":155.39999985694885},{"duration":298.89999985694885,"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":155.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":155.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":454.39999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":298.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":155.59999990463257,"connectEnd":155.59999990463257,"connectStart":155.59999990463257,"domainLookupEnd":155.59999990463257,"domainLookupStart":155.59999990463257,"fetchStart":155.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":155.59999990463257,"responseEnd":454.39999985694885,"responseStart":454.39999985694885,"secureConnectionStart":155.59999990463257},{"duration":299.30000019073486,"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":155.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":155.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":455,"responseStart":0,"secureConnectionStart":0},{"duration":299.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":155.79999995231628,"connectEnd":155.79999995231628,"connectStart":155.79999995231628,"domainLookupEnd":155.79999995231628,"domainLookupStart":155.79999995231628,"fetchStart":155.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":155.79999995231628,"responseEnd":455.09999990463257,"responseStart":455.09999990463257,"secureConnectionStart":155.79999995231628},{"duration":408.09999990463257,"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":156.5,"connectEnd":156.5,"connectStart":156.5,"domainLookupEnd":156.5,"domainLookupStart":156.5,"fetchStart":156.5,"redirectEnd":0,"redirectStart":0,"requestStart":156.5,"responseEnd":564.5999999046326,"responseStart":564.5999999046326,"secureConnectionStart":156.5},{"duration":705.2999999523163,"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":156.59999990463257,"connectEnd":156.59999990463257,"connectStart":156.59999990463257,"domainLookupEnd":156.59999990463257,"domainLookupStart":156.59999990463257,"fetchStart":156.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":156.59999990463257,"responseEnd":861.8999998569489,"responseStart":861.8999998569489,"secureConnectionStart":156.59999990463257},{"duration":88.09999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":477.7999999523163,"connectEnd":477.7999999523163,"connectStart":477.7999999523163,"domainLookupEnd":477.7999999523163,"domainLookupStart":477.7999999523163,"fetchStart":477.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":477.7999999523163,"responseEnd":565.8999998569489,"responseStart":565.8999998569489,"secureConnectionStart":477.7999999523163},{"duration":261.7000000476837,"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":730.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":730.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":992.3999998569489,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":11,"responseStart":145,"responseEnd":146,"domLoading":152,"domInteractive":938,"domContentLoadedEventStart":938,"domContentLoadedEventEnd":982,"domComplete":1758,"loadEventStart":1758,"loadEventEnd":1760,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":918.2999999523163},{"name":"bigPipe.sidebar-id.end","time":919.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":919.3999998569489},{"name":"bigPipe.activity-panel-pipe-id.end","time":921.6999998092651},{"name":"activityTabFullyLoaded","time":993.2999999523163}],"measures":[],"correlationId":"74b5d7c1ef15d0","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":80,"dbReadsTimeInMs":10,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}