We noticed one issue on MariaDB 10.4.17 , the primary key isn't used on range lookups (full table scan is done):
|
# show create table jos_email_message\G
|
|
Table: jos_email_message
|
Create Table: CREATE TABLE `jos_email_message` (
|
`id` int(11) NOT NULL,
|
`email_message` longtext NOT NULL,
|
PRIMARY KEY (`id`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2
|
# explain format=json SELECT count(id) FROM jos_email_message WHERE `id` between 2114506 AND 2114624\G
|
|
EXPLAIN: {
|
"query_block": {
|
"select_id": 1,
|
"table": {
|
"table_name": "jos_email_message",
|
"access_type": "index",
|
"possible_keys": ["PRIMARY"],
|
"key": "PRIMARY",
|
"key_length": "4",
|
"used_key_parts": ["id"],
|
"rows": 20489158,
|
"filtered": 5.8e-4,
|
"attached_condition": "jos_email_message.`id` between 2114506 and 2114624",
|
"using_index": true
|
}
|
}
|
}
|
# explain SELECT count(`id`) FROM jos_email_message WHERE `id` between 2114506 AND 2114624;
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
| 1 | SIMPLE | jos_email_message | index | PRIMARY | PRIMARY | 4 | NULL | 20489158 | Using where; Using index |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
1 row in set (0.001 sec)
|
|
# explain SELECT count(`id`) FROM jos_email_message WHERE `id` >= 2114506;
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
| 1 | SIMPLE | jos_email_message | index | PRIMARY | PRIMARY | 4 | NULL | 20489158 | Using where; Using index |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
1 row in set (0.006 sec)
|
|
# explain SELECT count(`id`) FROM jos_email_message WHERE `id` <= 2114506;
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
| 1 | SIMPLE | jos_email_message | index | PRIMARY | PRIMARY | 4 | NULL | 20489158 | Using where; Using index |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+----------+--------------------------+
|
1 row in set (0.004 sec)
|
|
# explain SELECT count(`id`) FROM jos_email_message WHERE `id` = 2114506;
|
+------+-------------+--------------------------+-------+---------------+---------+---------+-------+------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+-------+------+-------------+
|
| 1 | SIMPLE | jos_email_message | const | PRIMARY | PRIMARY | 4 | const | 1 | Using index |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+-------+------+-------------+
|
1 row in set (0.001 sec)
|
|
We didn't have this problem on 10.4.13, prior to upgrading to 10.4.17, and we don't have this problem on 10.3.27 (master data)
# explain SELECT count(`id`) FROM jos_email_message WHERE `id` between 2114506 AND 2114624;
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+------+--------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+------+--------------------------+
|
| 1 | SIMPLE | jos_email_message | range | PRIMARY | PRIMARY | 4 | NULL | 119 | Using where; Using index |
|
+------+-------------+--------------------------+-------+---------------+---------+---------+------+------+--------------------------+
|
|
We've tried re-creating the table, doing analyze and forcing the index, they didn't do any difference:
- ANALYZE TABLE jos_email_message;
- ALTER TABLE jos_email_message FORCE;
- SELECT count(`id`) FROM jos_email_message FORCE INDEX(`PRIMARY`) WHERE `id` between 2114506 AND 2114624;
I've done a copy of the table, but using a simple string on email_message field, instead of the HTML text we usually store there:
- CREATE TABLE test_tbl LIKE jos_email_message;
- INSERT INTO test_tbl SELECT id,'test' FROM jos_email_message;
and on the new table the index lookup works just fine:
# explain SELECT count(`id`) FROM `test_tbl` WHERE `id` between 2114506 AND 2114624;
|
+------+-------------+-------+-------+---------------+---------+---------+------+------+--------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+-------+---------------+---------+---------+------+------+--------------------------+
|
| 1 | SIMPLE | test_tbl | range | PRIMARY | PRIMARY | 4 | NULL | 119 | Using where; Using index |
|
+------+-------------+-------+-------+---------------+---------+---------+------+------+--------------------------+
|
The only difference between those two would be the size, the original one is around 64Gb and the test one was only around 500Mb.
Again, we didn't face this problem on 10.4.13 and don't have this problem on 10.3.27 with the exact same data.
Seems to be a regression introduced recently in MariaDB 10.4 branch.
Just let me know if you need any other info.
{"report":{"fcp":1532.4000000953674,"ttfb":253,"pageVisibility":"visible","entityId":95304,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"88b2d043-d696-4c25-8905-93b264bf4d9d","navigationType":0,"readyForUser":1643.1999998092651,"redirectCount":0,"resourceLoadedEnd":1709.9000000953674,"resourceLoadedStart":259.40000009536743,"resourceTiming":[{"duration":651.5999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":259.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":259.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":911,"responseStart":0,"secureConnectionStart":0},{"duration":651.7000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":259.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":259.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":911.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":667.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":259.90000009536743,"connectEnd":259.90000009536743,"connectStart":259.90000009536743,"domainLookupEnd":259.90000009536743,"domainLookupStart":259.90000009536743,"fetchStart":259.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":259.90000009536743,"responseEnd":927.5999999046326,"responseStart":927.5,"secureConnectionStart":259.90000009536743},{"duration":744,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":260.09999990463257,"connectEnd":260.09999990463257,"connectStart":260.09999990463257,"domainLookupEnd":260.09999990463257,"domainLookupStart":260.09999990463257,"fetchStart":260.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":260.09999990463257,"responseEnd":1004.0999999046326,"responseStart":1004.0999999046326,"secureConnectionStart":260.09999990463257},{"duration":780.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":260.2999997138977,"connectEnd":260.2999997138977,"connectStart":260.2999997138977,"domainLookupEnd":260.2999997138977,"domainLookupStart":260.2999997138977,"fetchStart":260.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":260.2999997138977,"responseEnd":1040.6999998092651,"responseStart":1040.6999998092651,"secureConnectionStart":260.2999997138977},{"duration":799.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":260.40000009536743,"connectEnd":260.40000009536743,"connectStart":260.40000009536743,"domainLookupEnd":260.40000009536743,"domainLookupStart":260.40000009536743,"fetchStart":260.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":260.40000009536743,"responseEnd":1059.6999998092651,"responseStart":1059.6999998092651,"secureConnectionStart":260.40000009536743},{"duration":810.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":260.59999990463257,"connectEnd":260.59999990463257,"connectStart":260.59999990463257,"domainLookupEnd":260.59999990463257,"domainLookupStart":260.59999990463257,"fetchStart":260.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":260.59999990463257,"responseEnd":1070.9000000953674,"responseStart":1070.9000000953674,"secureConnectionStart":260.59999990463257},{"duration":876.8000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":260.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":260.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1137.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":814.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":261.09999990463257,"connectEnd":261.09999990463257,"connectStart":261.09999990463257,"domainLookupEnd":261.09999990463257,"domainLookupStart":261.09999990463257,"fetchStart":261.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":261.09999990463257,"responseEnd":1075.4000000953674,"responseStart":1075.4000000953674,"secureConnectionStart":261.09999990463257},{"duration":876.4000000953674,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":261.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":261.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1137.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":815,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":261.2999997138977,"connectEnd":261.2999997138977,"connectStart":261.2999997138977,"domainLookupEnd":261.2999997138977,"domainLookupStart":261.2999997138977,"fetchStart":261.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":261.2999997138977,"responseEnd":1076.2999997138977,"responseStart":1076.2999997138977,"secureConnectionStart":261.2999997138977},{"duration":950.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":267.69999980926514,"connectEnd":267.69999980926514,"connectStart":267.69999980926514,"domainLookupEnd":267.69999980926514,"domainLookupStart":267.69999980926514,"fetchStart":267.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":267.69999980926514,"responseEnd":1218.0999999046326,"responseStart":1218.0999999046326,"secureConnectionStart":267.69999980926514},{"duration":1035.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":267.7999997138977,"connectEnd":267.7999997138977,"connectStart":267.7999997138977,"domainLookupEnd":267.7999997138977,"domainLookupStart":267.7999997138977,"fetchStart":267.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":267.7999997138977,"responseEnd":1303.5999999046326,"responseStart":1303.5999999046326,"secureConnectionStart":267.7999997138977},{"duration":75.7000002861023,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1158.1999998092651,"connectEnd":1158.1999998092651,"connectStart":1158.1999998092651,"domainLookupEnd":1158.1999998092651,"domainLookupStart":1158.1999998092651,"fetchStart":1158.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1158.1999998092651,"responseEnd":1233.9000000953674,"responseStart":1233.9000000953674,"secureConnectionStart":1158.1999998092651},{"duration":241,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/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&whisper-enabled=true","startTime":1442,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1442,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1683,"responseStart":0,"secureConnectionStart":0},{"duration":259.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/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&whisper-enabled=true","startTime":1443,"connectEnd":1443,"connectStart":1443,"domainLookupEnd":1443,"domainLookupStart":1443,"fetchStart":1443,"redirectEnd":0,"redirectStart":0,"requestStart":1443,"responseEnd":1702.7999997138977,"responseStart":1702.7999997138977,"secureConnectionStart":1443},{"duration":266.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/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&whisper-enabled=true","startTime":1443.4000000953674,"connectEnd":1443.4000000953674,"connectStart":1443.4000000953674,"domainLookupEnd":1443.4000000953674,"domainLookupStart":1443.4000000953674,"fetchStart":1443.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1443.4000000953674,"responseEnd":1709.9000000953674,"responseStart":1709.9000000953674,"secureConnectionStart":1443.4000000953674},{"duration":191.40000009536743,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1525.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1525.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1716.9000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":80,"responseStart":253,"responseEnd":268,"domLoading":258,"domInteractive":1717,"domContentLoadedEventStart":1718,"domContentLoadedEventEnd":1769,"domComplete":2223,"loadEventStart":2223,"loadEventEnd":2224,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1691.4000000953674},{"name":"bigPipe.sidebar-id.end","time":1692.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1692.2999997138977},{"name":"bigPipe.activity-panel-pipe-id.end","time":1694.9000000953674},{"name":"activityTabFullyLoaded","time":1782.4000000953674}],"measures":[],"correlationId":"5ea2d5e4a307bb","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":99,"dbReadsTimeInMs":13,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}