There was apparently some regression introduced between versions 10.4.21 and 10.4.31, as the same test shows a dramatic decrease in SELECT COUNT(*) performance when a big enough transaction is active with uncommitted row changes.
How to reproduce:
– prepare 10M sysbench table
– start trx and delete random 4k rows
– run select count(*)
Example runs for various versions:
$ cat test_count_in_trx.sql
|
|
use db1
|
select count(*) from sbtest1;
|
|
start transaction;
|
DELETE FROM sbtest1 ORDER BY RAND() LIMIT 4000;
|
select count(*) from sbtest1;
|
rollback;
|
MariaDB 10.4.21
$ msb_10_4_21/use -vvv < test_count_in_trx.sql
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 10000000 |
|
+----------+
|
1 row in set (2.070 sec)
|
|
--------------
|
start transaction
|
--------------
|
|
Query OK, 0 rows affected (0.000 sec)
|
|
--------------
|
DELETE FROM sbtest1 ORDER BY RAND() LIMIT 4000
|
--------------
|
|
Query OK, 4000 rows affected (12.723 sec)
|
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 9996000 |
|
+----------+
|
1 row in set (53.875 sec)
|
|
--------------
|
rollback
|
--------------
|
|
Query OK, 0 rows affected (0.451 sec)
|
MariaDB 10.4.31
$ msb_10_4_31/use db1 -vvv < test_count_in_trx.sql
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 10000000 |
|
+----------+
|
1 row in set (1.959 sec)
|
|
--------------
|
start transaction
|
--------------
|
|
Query OK, 0 rows affected (0.000 sec)
|
|
--------------
|
DELETE FROM sbtest1 ORDER BY RAND() LIMIT 4000
|
--------------
|
|
Query OK, 4000 rows affected (11.911 sec)
|
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 9996000 |
|
+----------+
|
1 row in set (11 min 41.352 sec)
|
|
--------------
|
rollback
|
--------------
|
|
Query OK, 0 rows affected (1.270 sec)
|
MariaDB 10.5.23
$ msb_10_5_23/use db1 -vvv < test_count_in_trx.sql
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 10000000 |
|
+----------+
|
1 row in set (1.940 sec)
|
|
--------------
|
start transaction
|
--------------
|
|
Query OK, 0 rows affected (0.000 sec)
|
|
--------------
|
DELETE FROM sbtest1 ORDER BY RAND() LIMIT 4000
|
--------------
|
|
Query OK, 4000 rows affected (13.320 sec)
|
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
1 row in set (13 min 14.588 sec)
|
|
--------------
|
rollback
|
--------------
|
|
Query OK, 0 rows affected (1.370 sec)
|
MySQL 8.0.35
$ msb_8_0_35/use db1 -vvv < test_count_in_trx.sql
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 10000000 |
|
+----------+
|
1 row in set (7.17 sec)
|
|
--------------
|
start transaction
|
--------------
|
|
Query OK, 0 rows affected (0.00 sec)
|
|
--------------
|
DELETE FROM sbtest1 ORDER BY RAND() LIMIT 4000
|
--------------
|
|
Query OK, 4000 rows affected (14.78 sec)
|
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 9996000 |
|
+----------+
|
1 row in set (9.46 sec)
|
|
--------------
|
rollback
|
--------------
|
|
Query OK, 0 rows affected (2.50 sec)
|
MySQL 5.7.44
$ msb_5_7_44/use -vvv < test_count_in_trx.sql
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 10000000 |
|
+----------+
|
1 row in set (2.17 sec)
|
|
--------------
|
start transaction
|
--------------
|
|
Query OK, 0 rows affected (0.00 sec)
|
|
--------------
|
DELETE FROM sbtest1 ORDER BY RAND() LIMIT 4000
|
--------------
|
|
Query OK, 4000 rows affected (15.24 sec)
|
|
--------------
|
select count(*) from sbtest1
|
--------------
|
|
+----------+
|
| count(*) |
|
+----------+
|
| 9996000 |
|
+----------+
|
1 row in set (8.08 sec)
|
|
--------------
|
rollback
|
--------------
|
|
Query OK, 0 rows affected (1.27 sec)
|
Ran all tests with default settings, i.e., buffer pool at 128MB.
- relates to
-
MDEV-36472
10.6 History length regression
-
-
Open
{"report":{"fcp":1137.7999999523163,"ttfb":439.7000000476837,"pageVisibility":"visible","entityId":127036,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"b19cdf0a-4617-4c5d-93b7-d447193fb8c2","navigationType":0,"readyForUser":1301.2999999523163,"redirectCount":0,"resourceLoadedEnd":1280.7000000476837,"resourceLoadedStart":445.09999990463257,"resourceTiming":[{"duration":248.70000004768372,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":445.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":445.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":693.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":248.39999985694885,"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":445.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":445.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":693.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":257.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":445.59999990463257,"connectEnd":445.59999990463257,"connectStart":445.59999990463257,"domainLookupEnd":445.59999990463257,"domainLookupStart":445.59999990463257,"fetchStart":445.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":445.59999990463257,"responseEnd":703.2999999523163,"responseStart":703.2999999523163,"secureConnectionStart":445.59999990463257},{"duration":284.2999999523163,"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":445.7000000476837,"connectEnd":445.7000000476837,"connectStart":445.7000000476837,"domainLookupEnd":445.7000000476837,"domainLookupStart":445.7000000476837,"fetchStart":445.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":445.7000000476837,"responseEnd":730,"responseStart":730,"secureConnectionStart":445.7000000476837},{"duration":288.2000000476837,"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":445.7999999523163,"connectEnd":445.7999999523163,"connectStart":445.7999999523163,"domainLookupEnd":445.7999999523163,"domainLookupStart":445.7999999523163,"fetchStart":445.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":445.7999999523163,"responseEnd":734,"responseStart":734,"secureConnectionStart":445.7999999523163},{"duration":288.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":445.90000009536743,"connectEnd":445.90000009536743,"connectStart":445.90000009536743,"domainLookupEnd":445.90000009536743,"domainLookupStart":445.90000009536743,"fetchStart":445.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":445.90000009536743,"responseEnd":734.5,"responseStart":734.5,"secureConnectionStart":445.90000009536743},{"duration":288.7999999523163,"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":446,"connectEnd":446,"connectStart":446,"domainLookupEnd":446,"domainLookupStart":446,"fetchStart":446,"redirectEnd":0,"redirectStart":0,"requestStart":446,"responseEnd":734.7999999523163,"responseStart":734.7999999523163,"secureConnectionStart":446},{"duration":289.10000014305115,"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":446.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":446.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":735.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":289,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":446.2000000476837,"connectEnd":446.2000000476837,"connectStart":446.2000000476837,"domainLookupEnd":446.2000000476837,"domainLookupStart":446.2000000476837,"fetchStart":446.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":446.2000000476837,"responseEnd":735.2000000476837,"responseStart":735.2000000476837,"secureConnectionStart":446.2000000476837},{"duration":289.2000000476837,"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":446.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":446.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":735.5,"responseStart":0,"secureConnectionStart":0},{"duration":289.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":446.40000009536743,"connectEnd":446.40000009536743,"connectStart":446.40000009536743,"domainLookupEnd":446.40000009536743,"domainLookupStart":446.40000009536743,"fetchStart":446.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":446.40000009536743,"responseEnd":735.7000000476837,"responseStart":735.7000000476837,"secureConnectionStart":446.40000009536743},{"duration":827,"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":452.7000000476837,"connectEnd":452.7000000476837,"connectStart":452.7000000476837,"domainLookupEnd":452.7000000476837,"domainLookupStart":452.7000000476837,"fetchStart":452.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":452.7000000476837,"responseEnd":1279.7000000476837,"responseStart":1279.7000000476837,"secureConnectionStart":452.7000000476837},{"duration":828,"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":452.7000000476837,"connectEnd":452.7000000476837,"connectStart":452.7000000476837,"domainLookupEnd":452.7000000476837,"domainLookupStart":452.7000000476837,"fetchStart":452.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":452.7000000476837,"responseEnd":1280.7000000476837,"responseStart":1280.7000000476837,"secureConnectionStart":452.7000000476837},{"duration":298.80000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":924.5999999046326,"connectEnd":924.5999999046326,"connectStart":924.5999999046326,"domainLookupEnd":924.5999999046326,"domainLookupStart":924.5999999046326,"fetchStart":924.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":924.5999999046326,"responseEnd":1223.4000000953674,"responseStart":1223.4000000953674,"secureConnectionStart":924.5999999046326},{"duration":228.40000009536743,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1101.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1101.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1329.9000000953674,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":7,"responseStart":439,"responseEnd":447,"domLoading":442,"domInteractive":1389,"domContentLoadedEventStart":1389,"domContentLoadedEventEnd":1433,"domComplete":2263,"loadEventStart":2263,"loadEventEnd":2264,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1328.4000000953674},{"name":"bigPipe.sidebar-id.end","time":1329.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":1329.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1331.7999999523163},{"name":"activityTabFullyLoaded","time":1442}],"measures":[],"correlationId":"d3548eb2814cf","effectiveType":"4g","downlink":9.2,"rtt":0,"serverDuration":349,"dbReadsTimeInMs":10,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}