This script:
set names utf8, collation_connection=utf8_swedish_ci;
|
drop table if exists t1;
|
create table t1 (a varchar(10) character set utf8,b int not null default 0, key(a));
|
insert into t1 (a) values ('a'),('b'),('c'),('d'),('¢');
|
set @arg='¢';
|
prepare stmt from "explain select * from t1 where a between _utf8'¢' and ?";
|
execute stmt using @arg;
|
prepare stmt from "explain select * from t1 where a between ? and _utf8'¢'";
|
execute stmt using @arg;
|
returns
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
| 1 | SIMPLE | t1 | range | a | a | 33 | NULL | 1 | Using index condition |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
|
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-----------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-----------------------+
|
| 1 | SIMPLE | t1 | ref | a | a | 33 | const | 1 | Using index condition |
|
+------+-------------+-------+------+---------------+------+---------+-------+------+-----------------------+
|
Notice, the first query is using RANGE, while the second query is using REF.
which means BETWEEN was changed to equality operator in the second
query.
If I run the same explains without a PS parameter:
set names utf8, collation_connection=utf8_swedish_ci;
|
explain select * from t1 where a between _utf8'¢' and '¢';
|
explain select * from t1 where a between '¢' and _utf8'¢';
|
It uses RANGE for both queries:
MariaDB [test]> explain select * from t1 where a between _utf8'¢' and '¢';
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
| 1 | SIMPLE | t1 | range | a | a | 33 | NULL | 1 | Using index condition |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [test]> explain select * from t1 where a between '¢' and _utf8'¢';
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
| 1 | SIMPLE | t1 | range | a | a | 33 | NULL | 1 | Using index condition |
|
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
|
1 row in set (0.00 sec)
|
|
It should be fixed to use exactly the same plan for all 4 queries.
{"report":{"fcp":703.5,"ttfb":144.70000004768372,"pageVisibility":"visible","entityId":44305,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":1,"journeyId":"f541ee5e-f850-4fbf-bf36-c74990f3a06b","navigationType":0,"readyForUser":817.7999999523163,"redirectCount":0,"resourceLoadedEnd":802.2000000476837,"resourceLoadedStart":150.09999990463257,"resourceTiming":[{"duration":140.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":150.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":150.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":290.5,"responseStart":0,"secureConnectionStart":0},{"duration":140.20000004768372,"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":150.29999995231628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":150.29999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":290.5,"responseStart":0,"secureConnectionStart":0},{"duration":149.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":150.5,"connectEnd":150.5,"connectStart":150.5,"domainLookupEnd":150.5,"domainLookupStart":150.5,"fetchStart":150.5,"redirectEnd":0,"redirectStart":0,"requestStart":150.5,"responseEnd":299.59999990463257,"responseStart":299.59999990463257,"secureConnectionStart":150.5},{"duration":238.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":150.59999990463257,"connectEnd":150.59999990463257,"connectStart":150.59999990463257,"domainLookupEnd":150.59999990463257,"domainLookupStart":150.59999990463257,"fetchStart":150.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":150.59999990463257,"responseEnd":389.09999990463257,"responseStart":389.09999990463257,"secureConnectionStart":150.59999990463257},{"duration":234.70000004768372,"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":150.59999990463257,"connectEnd":150.59999990463257,"connectStart":150.59999990463257,"domainLookupEnd":150.59999990463257,"domainLookupStart":150.59999990463257,"fetchStart":150.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":150.59999990463257,"responseEnd":385.2999999523163,"responseStart":385.2999999523163,"secureConnectionStart":150.59999990463257},{"duration":238.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":150.79999995231628,"connectEnd":150.79999995231628,"connectStart":150.79999995231628,"domainLookupEnd":150.79999995231628,"domainLookupStart":150.79999995231628,"fetchStart":150.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":150.79999995231628,"responseEnd":389.7000000476837,"responseStart":389.7000000476837,"secureConnectionStart":150.79999995231628},{"duration":239.29999995231628,"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":150.79999995231628,"connectEnd":150.79999995231628,"connectStart":150.79999995231628,"domainLookupEnd":150.79999995231628,"domainLookupStart":150.79999995231628,"fetchStart":150.79999995231628,"redirectEnd":0,"redirectStart":0,"requestStart":150.79999995231628,"responseEnd":390.09999990463257,"responseStart":390.09999990463257,"secureConnectionStart":150.79999995231628},{"duration":239.80000019073486,"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":150.89999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":150.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":390.7000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":239.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":151,"connectEnd":151,"connectStart":151,"domainLookupEnd":151,"domainLookupStart":151,"fetchStart":151,"redirectEnd":0,"redirectStart":0,"requestStart":151,"responseEnd":390.59999990463257,"responseStart":390.59999990463257,"secureConnectionStart":151},{"duration":239.89999985694885,"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":151.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":151.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":391.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":239.70000004768372,"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":151.39999985694885,"connectEnd":151.39999985694885,"connectStart":151.39999985694885,"domainLookupEnd":151.39999985694885,"domainLookupStart":151.39999985694885,"fetchStart":151.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":151.39999985694885,"responseEnd":391.09999990463257,"responseStart":391.09999990463257,"secureConnectionStart":151.39999985694885},{"duration":293.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":151.89999985694885,"connectEnd":151.89999985694885,"connectStart":151.89999985694885,"domainLookupEnd":151.89999985694885,"domainLookupStart":151.89999985694885,"fetchStart":151.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":151.89999985694885,"responseEnd":445.7999999523163,"responseStart":445.7999999523163,"secureConnectionStart":151.89999985694885},{"duration":334.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":152,"connectEnd":152,"connectStart":152,"domainLookupEnd":152,"domainLookupStart":152,"fetchStart":152,"redirectEnd":0,"redirectStart":0,"requestStart":152,"responseEnd":486.5,"responseStart":486.5,"secureConnectionStart":152},{"duration":21.100000143051147,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":465.89999985694885,"connectEnd":465.89999985694885,"connectStart":465.89999985694885,"domainLookupEnd":465.89999985694885,"domainLookupStart":465.89999985694885,"fetchStart":465.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":465.89999985694885,"responseEnd":487,"responseStart":487,"secureConnectionStart":465.89999985694885},{"duration":100.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":696.7000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":696.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":797.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":93.79999995231628,"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":703.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":703.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":797.2999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":93.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":704.2999999523163,"connectEnd":704.2999999523163,"connectStart":704.2999999523163,"domainLookupEnd":704.2999999523163,"domainLookupStart":704.2999999523163,"fetchStart":704.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":704.2999999523163,"responseEnd":797.7000000476837,"responseStart":797.7000000476837,"secureConnectionStart":704.2999999523163},{"duration":97.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/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.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":704.7000000476837,"connectEnd":704.7000000476837,"connectStart":704.7000000476837,"domainLookupEnd":704.7000000476837,"domainLookupStart":704.7000000476837,"fetchStart":704.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":704.7000000476837,"responseEnd":802.2000000476837,"responseStart":802.2000000476837,"secureConnectionStart":704.7000000476837}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":17,"responseStart":145,"responseEnd":148,"domLoading":148,"domInteractive":889,"domContentLoadedEventStart":889,"domContentLoadedEventEnd":936,"domComplete":1325,"loadEventStart":1325,"loadEventEnd":1326,"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.5999999046326},{"name":"bigPipe.sidebar-id.end","time":860.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":860.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":863.0999999046326},{"name":"activityTabFullyLoaded","time":946.5}],"measures":[],"correlationId":"1a3ffd8c50c883","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":68,"dbReadsTimeInMs":7,"dbConnsTimeInMs":14,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}