Deleting as many records may take some time, I think it is as fast as possible, if you do so. If you do not want to invest in faster equipment, I propose a different approach:
If you really want to delete 220 million records so that only 15,000 records remain in the table, this is about 99.999% of all records. Why not
- Create a new table,
- just insert all the records you want to survive,
- and replace the old with the new?
Something like this might work a little faster:
CREATE TABLE matches_new SELECT a.* FROM matches a LEFT JOIN matches b ON (a.uid = b.matcheduid) WHERE ISNULL (b.matcheduid) RENAME TABLE matches TO matches_old; RENAME TABLE matches_new TO matches;
After that, you just need to check and create the necessary indexes, which should be quite fast, if only to deal with 15,000 records.
Bjoern
source share