As a best practice before dropping a large table in MySQL, pt-archiver can be used to delete all the records in batches. This helps to avoid a situation where your server may get stalled under certain circumstances.
I recently read a comment from a user saying “The pt-archiver is not working as expected! It is skipping the last record, which seems like a bug.”. Let’s examine pt-archiver’s default behavior and understand why the author of this comment believes that pt-archiver is bugged (Spoiler: It’s not!).
But wait, before continuing on busting the blame, let me clarify why to use pt-archiver before dropping large tables.
When we drop a table in MySQL:
- Table data/index (ibd) and definition (frm) files are removed.
- Triggers are removed.
- Table definition cache is updated by removing the table being dropped.
- InnoDB buffer pool is scanned for associated pages to …