Two tables:
aggregated_data.xx_aggregated_ad_revenue (~1150 rows) and xx_tracker.ad_revenue (~60,000 rows), running the following delete query as a stored procedure on our old machine with Percona Server (GPL), Release rel29.0, Revision 315 (5.5.27-29.0-log) takes seconds up to 1-2 minutes, same query on MariaDB 10 takes more than 7000 seconds.
-- DB: aggregated_data
|
-- Command: Query
|
-- Time: 7103
|
-- State: updating
|
DELETE FROM aggregated_data.xx_aggregated_ad_revenue
|
WHERE network = 'networkA' AND booking_date IN (
|
SELECT CONCAT(SUBSTRING(a.booking_date,-4), SUBSTRING(a.booking_date,3,2), SUBSTRING(a.booking_date,1,2)) AS booking_date
|
FROM xx_tracker.ad_revenue a
|
JOIN
|
(
|
SELECT CONCAT(SUBSTRING(booking_date,-4), SUBSTRING(booking_date,3,2), SUBSTRING(booking_date,1,2)) AS booking_date, MAX(created_ts) AS max_ts
|
FROM xx_tracker.ad_revenue b
|
WHERE network = 'networkA'
|
GROUP BY b.booking_date
|
) AS i
|
ON CONCAT(SUBSTRING(a.booking_date,-4), SUBSTRING(a.booking_date,3,2), SUBSTRING(a.booking_date,1,2)) = i.booking_date AND i.max_ts = a.created_ts
|
WHERE a.created_ts >= NOW() - INTERVAL 1 DAY
|
)
|
Even though the same indices exist on Percona and MariaDB (tables have been created by dumping the definitions are exactly the same) - MariaDB is using a key (EXPLAIN of subselect: http://puu.sh/7Zjuh.png), where Percona does not (EXPLAIN of subselect: http://puu.sh/7ZjuT.png - but Percona is way faster.
EXPLAIN DELETE for MariaDB 10: http://puu.sh/7ZjDl.png
Indices on aggregated_data.xx_aggregated_ad_revenue:
1: PRIMARY id, created_date
2: created_date
3: network
Indices on xx_tracker.ad_revenue:
1. PRIMARY id, created_date
2. created_date
3. network
Running the Subselect of the DELETE alone is fast (< 1-2 seconds). The query is a stored procedure which spends 95% of the time in the "Sending data" state.
{"report":{"fcp":934.9000000059605,"ttfb":170,"pageVisibility":"visible","entityId":34600,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a02b772c-5b14-49da-a3cb-a2ff3b7ca0a3","navigationType":0,"readyForUser":1053.300000011921,"redirectCount":0,"resourceLoadedEnd":1136.800000011921,"resourceLoadedStart":175.5,"resourceTiming":[{"duration":15.400000005960464,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":175.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":175.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":190.90000000596046,"responseStart":0,"secureConnectionStart":0},{"duration":15.799999997019768,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":175.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":175.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":191.6000000089407,"responseStart":0,"secureConnectionStart":0},{"duration":71.40000000596046,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":175.90000000596046,"connectEnd":175.90000000596046,"connectStart":175.90000000596046,"domainLookupEnd":175.90000000596046,"domainLookupStart":175.90000000596046,"fetchStart":175.90000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":175.90000000596046,"responseEnd":247.30000001192093,"responseStart":247.30000001192093,"secureConnectionStart":175.90000000596046},{"duration":413,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":176.20000000298023,"connectEnd":176.20000000298023,"connectStart":176.20000000298023,"domainLookupEnd":176.20000000298023,"domainLookupStart":176.20000000298023,"fetchStart":176.20000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":176.20000000298023,"responseEnd":589.2000000029802,"responseStart":589.2000000029802,"secureConnectionStart":176.20000000298023},{"duration":416.30000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":176.5,"connectEnd":176.5,"connectStart":176.5,"domainLookupEnd":176.5,"domainLookupStart":176.5,"fetchStart":176.5,"redirectEnd":0,"redirectStart":0,"requestStart":176.5,"responseEnd":592.8000000119209,"responseStart":592.8000000119209,"secureConnectionStart":176.5},{"duration":416.70000000298023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":176.6000000089407,"connectEnd":176.6000000089407,"connectStart":176.6000000089407,"domainLookupEnd":176.6000000089407,"domainLookupStart":176.6000000089407,"fetchStart":176.6000000089407,"redirectEnd":0,"redirectStart":0,"requestStart":176.6000000089407,"responseEnd":593.3000000119209,"responseStart":593.3000000119209,"secureConnectionStart":176.6000000089407},{"duration":417.1000000089407,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":176.70000000298023,"connectEnd":176.70000000298023,"connectStart":176.70000000298023,"domainLookupEnd":176.70000000298023,"domainLookupStart":176.70000000298023,"fetchStart":176.70000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":176.70000000298023,"responseEnd":593.8000000119209,"responseStart":593.7000000029802,"secureConnectionStart":176.70000000298023},{"duration":417.90000000596046,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":177,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":177,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":594.9000000059605,"responseStart":0,"secureConnectionStart":0},{"duration":417,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":177.1000000089407,"connectEnd":177.1000000089407,"connectStart":177.1000000089407,"domainLookupEnd":177.1000000089407,"domainLookupStart":177.1000000089407,"fetchStart":177.1000000089407,"redirectEnd":0,"redirectStart":0,"requestStart":177.1000000089407,"responseEnd":594.1000000089407,"responseStart":594.1000000089407,"secureConnectionStart":177.1000000089407},{"duration":417.69999998807907,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":177.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":177.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":595,"responseStart":0,"secureConnectionStart":0},{"duration":417.29999999701977,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":177.40000000596046,"connectEnd":177.40000000596046,"connectStart":177.40000000596046,"domainLookupEnd":177.40000000596046,"domainLookupStart":177.40000000596046,"fetchStart":177.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":177.40000000596046,"responseEnd":594.7000000029802,"responseStart":594.7000000029802,"secureConnectionStart":177.40000000596046},{"duration":568.1999999880791,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":178.30000001192093,"connectEnd":178.30000001192093,"connectStart":178.30000001192093,"domainLookupEnd":178.30000001192093,"domainLookupStart":178.30000001192093,"fetchStart":178.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":178.30000001192093,"responseEnd":746.5,"responseStart":746.5,"secureConnectionStart":178.30000001192093},{"duration":957.5999999940395,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":178.40000000596046,"connectEnd":178.40000000596046,"connectStart":178.40000000596046,"domainLookupEnd":178.40000000596046,"domainLookupStart":178.40000000596046,"fetchStart":178.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":178.40000000596046,"responseEnd":1136,"responseStart":1136,"secureConnectionStart":178.40000000596046},{"duration":349.1000000089407,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":396.70000000298023,"connectEnd":396.70000000298023,"connectStart":396.70000000298023,"domainLookupEnd":396.70000000298023,"domainLookupStart":396.70000000298023,"fetchStart":396.70000000298023,"redirectEnd":0,"redirectStart":0,"requestStart":396.70000000298023,"responseEnd":745.8000000119209,"responseStart":745.8000000119209,"secureConnectionStart":396.70000000298023},{"duration":266.40000000596046,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bv2/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":870.4000000059605,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":870.4000000059605,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1136.800000011921,"responseStart":0,"secureConnectionStart":0},{"duration":287,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/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":871.4000000059605,"connectEnd":871.4000000059605,"connectStart":871.4000000059605,"domainLookupEnd":871.4000000059605,"domainLookupStart":871.4000000059605,"fetchStart":871.4000000059605,"redirectEnd":0,"redirectStart":0,"requestStart":871.4000000059605,"responseEnd":1158.4000000059605,"responseStart":1158.4000000059605,"secureConnectionStart":871.4000000059605},{"duration":294.09999999403954,"initiatorType":"script","name":"https://jira.mariadb.org/s/53a43b6764f587426c7bb9a150184c00-CDN/lu2bv2/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":871.9000000059605,"connectEnd":871.9000000059605,"connectStart":871.9000000059605,"domainLookupEnd":871.9000000059605,"domainLookupStart":871.9000000059605,"fetchStart":871.9000000059605,"redirectEnd":0,"redirectStart":0,"requestStart":871.9000000059605,"responseEnd":1166,"responseStart":1166,"secureConnectionStart":871.9000000059605}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":19,"responseStart":170,"responseEnd":172,"domLoading":173,"domInteractive":1157,"domContentLoadedEventStart":1157,"domContentLoadedEventEnd":1199,"domComplete":2368,"loadEventStart":2368,"loadEventEnd":2370,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1138},{"name":"bigPipe.sidebar-id.end","time":1138.800000011921},{"name":"bigPipe.activity-panel-pipe-id.start","time":1139},{"name":"bigPipe.activity-panel-pipe-id.end","time":1141.6000000089407},{"name":"activityTabFullyLoaded","time":1207.1000000089407}],"measures":[],"correlationId":"754f10998367f5","effectiveType":"4g","downlink":9.4,"rtt":0,"serverDuration":91,"dbReadsTimeInMs":9,"dbConnsTimeInMs":17,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}