Maintaining partitioned tables in MySQL can be tedious. In a reporting database that uses monthly date partitions, I've found that I can simplify many frequent partition operations using the common_schema QueryScript language. Below I will describe two specific examples.
Removing old data
I like to keep a 2-3 month window of data in some of my reporting
tables. In order to maintain that window I periodically purge
data more than 3 months old using the TRUNCATE
PARTITION command. Since I want to apply the same purge
logic to all tables matching a consistent naming pattern, I can
use the common_schema …