When using varchar/char type of index , there is excessive "Using where" in the result of explain command.
This cause unnecessary string comparison in query.
test case:
CREATE TABLE `tmp_xf_like` (
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`user_id` bigint(20) NOT NULL,
|
`title` varchar(128) NOT NULL,
|
`memo` varchar(2000) DEFAULT NULL,
|
PRIMARY KEY (`id`),
|
KEY `idx_userid` (`title`),
|
KEY `user_id` (`user_id`)
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
|
|
mysql> explain select id from tmp_xf_like where title='a';
|
+----+-------------+-------------+------+---------------+------------+---------+-------+------+--------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+----+-------------+-------------+------+---------------+------------+---------+-------+------+--------------------------+
|
| 1 | SIMPLE | tmp_xf_like | ref | idx_userid | idx_userid | 386 | const | 1 | Using where; Using index |
|
+----+-------------+-------------+------+---------------+------------+---------+-------+------+--------------------------+
|
1 row in set (0.01 sec)
|
The result is the same after changing field "title" into binary
But INT type looks normal.
explain select id from tmp_xf_like where user_id=1;
|
+----+-------------+-------------+------+---------------+---------+---------+-------+------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+----+-------------+-------------+------+---------------+---------+---------+-------+------+-------------+
|
| 1 | SIMPLE | tmp_xf_like | ref | user_id | user_id | 8 | const | 1 | Using index |
|
+----+-------------+-------------+------+---------------+---------+---------+-------+------+-------------+
|
1 row in set (0.00 sec)
|
No workflow transitions have been executed yet.
{"report":{"fcp":943.3999999761581,"ttfb":242.5,"pageVisibility":"visible","entityId":19629,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"577f911b-3acf-4d5b-9e66-7af2a9c01249","navigationType":0,"readyForUser":1016.1999999880791,"redirectCount":0,"resourceLoadedEnd":1172.199999988079,"resourceLoadedStart":248.39999997615814,"resourceTiming":[{"duration":216.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":248.39999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":248.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":464.89999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":216.5,"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":248.69999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":248.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":465.19999998807907,"responseStart":0,"secureConnectionStart":0},{"duration":232,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":248.80000001192093,"connectEnd":248.80000001192093,"connectStart":248.80000001192093,"domainLookupEnd":248.80000001192093,"domainLookupStart":248.80000001192093,"fetchStart":248.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":248.80000001192093,"responseEnd":480.80000001192093,"responseStart":480.80000001192093,"secureConnectionStart":248.80000001192093},{"duration":304,"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":249,"connectEnd":249,"connectStart":249,"domainLookupEnd":249,"domainLookupStart":249,"fetchStart":249,"redirectEnd":0,"redirectStart":0,"requestStart":249,"responseEnd":553,"responseStart":552.8999999761581,"secureConnectionStart":249},{"duration":307.69999998807907,"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":249.30000001192093,"connectEnd":249.30000001192093,"connectStart":249.30000001192093,"domainLookupEnd":249.30000001192093,"domainLookupStart":249.30000001192093,"fetchStart":249.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":249.30000001192093,"responseEnd":557,"responseStart":556.8999999761581,"secureConnectionStart":249.30000001192093},{"duration":308.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":249.39999997615814,"connectEnd":249.39999997615814,"connectStart":249.39999997615814,"domainLookupEnd":249.39999997615814,"domainLookupStart":249.39999997615814,"fetchStart":249.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":249.39999997615814,"responseEnd":558.1000000238419,"responseStart":558.1000000238419,"secureConnectionStart":249.39999997615814},{"duration":308.89999997615814,"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":249.60000002384186,"connectEnd":249.60000002384186,"connectStart":249.60000002384186,"domainLookupEnd":249.60000002384186,"domainLookupStart":249.60000002384186,"fetchStart":249.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":249.60000002384186,"responseEnd":558.5,"responseStart":558.5,"secureConnectionStart":249.60000002384186},{"duration":374.10000002384186,"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":249.69999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":249.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":623.8000000119209,"responseStart":0,"secureConnectionStart":0},{"duration":309.2000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":249.89999997615814,"connectEnd":249.89999997615814,"connectStart":249.89999997615814,"domainLookupEnd":249.89999997615814,"domainLookupStart":249.89999997615814,"fetchStart":249.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":249.89999997615814,"responseEnd":559.1000000238419,"responseStart":559.1000000238419,"secureConnectionStart":249.89999997615814},{"duration":373.89999997615814,"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":250,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":250,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":623.8999999761581,"responseStart":0,"secureConnectionStart":0},{"duration":309.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":250.19999998807907,"connectEnd":250.19999998807907,"connectStart":250.19999998807907,"domainLookupEnd":250.19999998807907,"domainLookupStart":250.19999998807907,"fetchStart":250.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":250.19999998807907,"responseEnd":559.6999999880791,"responseStart":559.6999999880791,"secureConnectionStart":250.19999998807907},{"duration":906.6999999880791,"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":255.19999998807907,"connectEnd":255.19999998807907,"connectStart":255.19999998807907,"domainLookupEnd":255.19999998807907,"domainLookupStart":255.19999998807907,"fetchStart":255.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":255.19999998807907,"responseEnd":1161.8999999761581,"responseStart":1161.8999999761581,"secureConnectionStart":255.19999998807907},{"duration":907.0999999642372,"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":255.30000001192093,"connectEnd":255.30000001192093,"connectStart":255.30000001192093,"domainLookupEnd":255.30000001192093,"domainLookupStart":255.30000001192093,"fetchStart":255.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":255.30000001192093,"responseEnd":1162.3999999761581,"responseStart":1162.3999999761581,"secureConnectionStart":255.30000001192093},{"duration":100.69999998807907,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":650.6999999880791,"connectEnd":650.6999999880791,"connectStart":650.6999999880791,"domainLookupEnd":650.6999999880791,"domainLookupStart":650.6999999880791,"fetchStart":650.6999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":650.6999999880791,"responseEnd":751.3999999761581,"responseStart":751.3999999761581,"secureConnectionStart":650.6999999880791},{"duration":265.80000001192093,"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":897.3999999761581,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":897.3999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1163.199999988079,"responseStart":0,"secureConnectionStart":0},{"duration":266.5999999642372,"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":898.3000000119209,"connectEnd":898.3000000119209,"connectStart":898.3000000119209,"domainLookupEnd":898.3000000119209,"domainLookupStart":898.3000000119209,"fetchStart":898.3000000119209,"redirectEnd":0,"redirectStart":0,"requestStart":898.3000000119209,"responseEnd":1164.8999999761581,"responseStart":1164.8999999761581,"secureConnectionStart":898.3000000119209},{"duration":246.69999998807907,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":936.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":936.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1183.199999988079,"responseStart":0,"secureConnectionStart":0},{"duration":273.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":898.6999999880791,"connectEnd":898.6999999880791,"connectStart":898.6999999880791,"domainLookupEnd":898.6999999880791,"domainLookupStart":898.6999999880791,"fetchStart":898.6999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":898.6999999880791,"responseEnd":1172.199999988079,"responseStart":1172.199999988079,"secureConnectionStart":898.6999999880791}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":73,"responseStart":243,"responseEnd":248,"domLoading":246,"domInteractive":1185,"domContentLoadedEventStart":1185,"domContentLoadedEventEnd":1224,"domComplete":1525,"loadEventStart":1525,"loadEventEnd":1526,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1169.5},{"name":"bigPipe.sidebar-id.end","time":1170.300000011921},{"name":"bigPipe.activity-panel-pipe-id.start","time":1170.3999999761581},{"name":"bigPipe.activity-panel-pipe-id.end","time":1171},{"name":"activityTabFullyLoaded","time":1267.699999988079}],"measures":[],"correlationId":"31227ac22d1e4d","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":105,"dbReadsTimeInMs":19,"dbConnsTimeInMs":28,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}