pt-archiver from Percona Toolkit is a widely used tool for MySQL data retention, but it relies on row-by-row DELETE statements even on partitioned tables, missing the dramatic performance benefits of ALTER TABLE DROP PARTITION. A custom Perl plugin for pt-archiver is presented that intercepts the archival process, inspects INFORMATION_SCHEMA.PARTITIONS, matches the WHERE cutoff date to partition boundaries, and executes DROP PARTITION instead of DELETE. This turns multi-hour purge operations into near-instant metadata operations. The plugin includes dry-run support, safety checks (refusing to act if no exact boundary match is found), and detailed logging. Caveats around metadata locks, backup awareness, and partition boundary alignment with retention policies are also discussed.

16m read timeFrom percona.com
Post cover image
Table of contents
156 Impressions