MySQL Forums
Forum List  »  InnoDB

Re: Delete statement taking more time for deleting 1 million records
Posted by: Rick James
Date: October 18, 2014 12:20PM

> which is the best way to delete all 1 million records in less time.

How fast do disks spin? That is your limiting factor.

OTOH, there is a possible solution. PARTITIONing. DROP PARTITION takes less than a second, even for a millions of records. See
http://mysql.rjweb.org/doc.php/deletebig

If you think partitioning won't work for you, or need further guidance, then please provide
SHOW CREATE TABLE
and explain which million rows you need to delete.

On the other hand...

> 2 millon records on the mysql database table and wanted to delete 1 million records

That smells like a one-time cleanup, not a monthly purge? In that case, it _may_ be faster to
CREATE TABLE new LIKE real;
INSERT INTO new SELECT * FROM real WHERE <rows to keep>;
RENAME TABLE real TO old, new TO real;
DROP TABLE old;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Delete statement taking more time for deleting 1 million records
1912
October 18, 2014 12:20PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.