This alert uses theDATA_FREEcolumn from INFORMATION_SCHEMA.TABLES view in MySQL to detect table bloat. This is the amount of allocated but unused space (in bytes) in a table’s storage, meaning space the table owns that currently holds no data.
Required permissions
The INFORMATION_SCHEMA.TABLES view provides metadata for tables across the entire MySQL instance. However, the DPA monitoring user must have the appropriate permissions on a table for it to be visible in this view. To grant the necessary access, you can execute commands similar to the examples below.
Keep in mind that DPA also requires SELECT privileges on the underlying tables to retrieve execution plans for queries. Therefore, these permissions may already have been granted as part of the initial DPA configuration. See Register a MySQL or Percona MySQL database instance for additional details.
GRANT SELECT ON <schema>.<table> TO dpa; -- grant permissions for a single table
GRANT SELECT ON <schema>.* TO dpa; -- grant permissions on all tables in a schema
GRANT SELECT ON *.* TO dpa; -- grant permissions on all tables in all schemas
What it means by engine
- InnoDB, file-per-table (the default): Free space inside the table’s own
.ibd file. It comes mostly from deleted rows, updates that shrink rows, and page splits, leaving gaps that later inserts can reuse but that the file doesn’t give back to the OS. - InnoDB, shared tablespace (
innodb_file_per_table=OFF or tables in the system tablespace): It reports the free space of the whole shared tablespace, so every table in it shows the same number. Don’t add these up. - MyISAM / Aria: Bytes in deleted-row gaps (the “dynamic row” overhead) within the data file.
Why it matters
- Reclaimable space: A large value relative to
data_length + index_length suggests fragmentation. OPTIMIZE TABLE (or ALTER TABLE ... ENGINE=InnoDB) rebuilds the table and returns the space to the filesystem. - Disk planning: It explains why a table’s file on disk is bigger than its logical size, and why deleting rows didn’t free any disk space.
- Performance: Heavy fragmentation means more pages to read for the same data, which can hurt scans and cache efficiency.
Caveats
- It’s an estimate, not an exact figure. For InnoDB, a small amount of free space is normal, since pages are deliberately not packed 100% full and there’s reserved space for growth.
- Reusable free space inside the file isn’t wasted, because new rows fill it before the file grows. It only matters when it’s large and not likely to be reused (after a big purge, for example).
DPA Alert Definition
Use the attached query in a DPA Custom Multiple Numeric alert, and follow the template below: