Optimizer does a wrong cast from column string to number instead of constant number to string:
source sales_flat_order_dump.sql
|
analyze table sales_flat_order;
|
|
explain
|
SELECT `main_table`.* FROM `sales_flat_order` AS `main_table` WHERE (`increment_id` >= 238900 AND `increment_id` <= 238907)
|
;
|
+------+-------------+------------+------+-----------------------------------+------+---------+------+--------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+------------+------+-----------------------------------+------+---------+------+--------+-------------+
|
| 1 | SIMPLE | main_table | ALL | UNQ_SALES_FLAT_ORDER_INCREMENT_ID | NULL | NULL | NULL | 260559 | Using where |
|
+------+-------------+------------+------+-----------------------------------+------+---------+------+--------+-------------+
|
|
Execution time:
3 rows in set (1.467 sec)
explain
|
SELECT `main_table`.* FROM `sales_flat_order` AS `main_table` WHERE (`increment_id` >= '238900' AND `increment_id` <= '238907')
|
;
|
+------+-------------+------------+-------+-----------------------------------+-----------------------------------+---------+------+------+-----------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+------------+-------+-----------------------------------+-----------------------------------+---------+------+------+-----------------------+
|
| 1 | SIMPLE | main_table | range | UNQ_SALES_FLAT_ORDER_INCREMENT_ID | UNQ_SALES_FLAT_ORDER_INCREMENT_ID | 153 | NULL | 3 | Using index condition |
|
+------+-------------+------------+-------+-----------------------------------+-----------------------------------+---------+------+------+-----------------------+
|
|
Execution time:
3 rows in set (0.002 sec)
This is reproducible at will. See example attached.
- is duplicated by
-
MDEV-18089
optimizer is wrong
-
-
Closed
{"report":{"fcp":743.7999999523163,"ttfb":190,"pageVisibility":"visible","entityId":103473,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"5701ee89-ea14-4323-b1b2-e4268ca1f196","navigationType":0,"readyForUser":823.1999998092651,"redirectCount":0,"resourceLoadedEnd":798,"resourceLoadedStart":195.39999985694885,"resourceTiming":[{"duration":50.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":195.39999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":245.89999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":50.200000047683716,"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":195.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":245.89999985694885,"responseStart":0,"secureConnectionStart":0},{"duration":69.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":195.69999980926514,"connectEnd":195.69999980926514,"connectStart":195.69999980926514,"domainLookupEnd":195.69999980926514,"domainLookupStart":195.69999980926514,"fetchStart":195.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":195.69999980926514,"responseEnd":265.19999980926514,"responseStart":265.19999980926514,"secureConnectionStart":195.69999980926514},{"duration":200.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":195.89999985694885,"connectEnd":195.89999985694885,"connectStart":195.89999985694885,"domainLookupEnd":195.89999985694885,"domainLookupStart":195.89999985694885,"fetchStart":195.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":195.89999985694885,"responseEnd":396.39999985694885,"responseStart":396.39999985694885,"secureConnectionStart":195.89999985694885},{"duration":204,"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":196,"connectEnd":196,"connectStart":196,"domainLookupEnd":196,"domainLookupStart":196,"fetchStart":196,"redirectEnd":0,"redirectStart":0,"requestStart":196,"responseEnd":400,"responseStart":400,"secureConnectionStart":196},{"duration":204.59999990463257,"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":196,"connectEnd":196,"connectStart":196,"domainLookupEnd":196,"domainLookupStart":196,"fetchStart":196,"redirectEnd":0,"redirectStart":0,"requestStart":196,"responseEnd":400.59999990463257,"responseStart":400.59999990463257,"secureConnectionStart":196},{"duration":204.90000009536743,"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":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":401.09999990463257,"responseStart":401.09999990463257,"secureConnectionStart":196.19999980926514},{"duration":205.29999995231628,"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":196.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":401.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":205.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":196.39999985694885,"connectEnd":196.39999985694885,"connectStart":196.39999985694885,"domainLookupEnd":196.39999985694885,"domainLookupStart":196.39999985694885,"fetchStart":196.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":196.39999985694885,"responseEnd":401.59999990463257,"responseStart":401.59999990463257,"secureConnectionStart":196.39999985694885},{"duration":205.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":196.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":402.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":205.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":196.59999990463257,"connectEnd":196.59999990463257,"connectStart":196.59999990463257,"domainLookupEnd":196.59999990463257,"domainLookupStart":196.59999990463257,"fetchStart":196.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":196.59999990463257,"responseEnd":402.19999980926514,"responseStart":402.19999980926514,"secureConnectionStart":196.59999990463257},{"duration":260.90000009536743,"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":197.19999980926514,"connectEnd":197.19999980926514,"connectStart":197.19999980926514,"domainLookupEnd":197.19999980926514,"domainLookupStart":197.19999980926514,"fetchStart":197.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":197.19999980926514,"responseEnd":458.09999990463257,"responseStart":458.09999990463257,"secureConnectionStart":197.19999980926514},{"duration":387.5,"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":197.29999995231628,"connectEnd":197.29999995231628,"connectStart":197.29999995231628,"domainLookupEnd":197.29999995231628,"domainLookupStart":197.29999995231628,"fetchStart":197.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":197.29999995231628,"responseEnd":584.7999999523163,"responseStart":584.7999999523163,"secureConnectionStart":197.29999995231628},{"duration":43.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":415.19999980926514,"connectEnd":415.19999980926514,"connectStart":415.19999980926514,"domainLookupEnd":415.19999980926514,"domainLookupStart":415.19999980926514,"fetchStart":415.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":415.19999980926514,"responseEnd":458.69999980926514,"responseStart":458.69999980926514,"secureConnectionStart":415.19999980926514},{"duration":329.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":468.59999990463257,"connectEnd":468.59999990463257,"connectStart":468.59999990463257,"domainLookupEnd":468.59999990463257,"domainLookupStart":468.59999990463257,"fetchStart":468.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":468.59999990463257,"responseEnd":798,"responseStart":798,"secureConnectionStart":468.59999990463257}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":45,"responseStart":190,"responseEnd":191,"domLoading":193,"domInteractive":881,"domContentLoadedEventStart":882,"domContentLoadedEventEnd":925,"domComplete":1345,"loadEventStart":1345,"loadEventEnd":1346,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":859.6999998092651},{"name":"bigPipe.sidebar-id.end","time":860.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":860.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":862.8999998569489},{"name":"activityTabFullyLoaded","time":936.3999998569489}],"measures":[],"correlationId":"d4586128961c26","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":80,"dbReadsTimeInMs":15,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}