This query needs to delete over 17 million rows, from a table containing 20 million.
DELETE FROM statements
where agreement_id IN (
select id FROM agreements
WHERE created < DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
);
DELETE FROM agreements
WHERE created < DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
It takes hours to run, am I missing something that could speed things up a bit?
The subselect by itself takes a few seconds, I don't understand why the delete takes so long.
innodb_log_file_size
- see dev.mysql.com/doc/refman/5.7/en/innodb-redo-log.html. A large innodb_buffer_size is also recommended.