I ran out of space in my database, so I did a backup on old records. Now I have to clear these records out, and my reference column is 'date'.
I tried using the standard approach:
DELETE FROM table WHERE date >= '2017-01-01' AND date <= '2017-12-31'
But this is obviously taking too much time, because there are more than 7 million rows to delete. Is there a way to speed this up? I'm trying to divide in months and even smaller chunks, but after running the code for some time, I get disconnected from the server.
Thanks in advance.
EDIT:
CREATE TABLE table (
id INT(11) NOT NULL AUTO_INCREMENT,
date DATE DEFAULT NULL,
# 18 more columns
PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 29616055,
AVG_ROW_LENGTH = 317,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci;