Delete-file rewriting consolidates delete state and affected data files, reducing the merge work queries must perform at read time. It is a recurring maintenance operation rather than a one-time cleanup task. section 11.1.3 section 11.1
Apply the technique according to table behavior:
- Run it aggressively for high-velocity CDC tables, especially in merge-on-read (MOR) workloads that accumulate many delete files. section 11.1.3
- Use table-specific schedules instead of imposing the same maintenance frequency on every dataset. section 11.1.3
- Coordinate execution through scheduled jobs, metadata-aware triggers, or conditional workflows so maintenance remains repeatable without constant oversight. section 11.1 section 11.1.2
Triggering maintenance from metadata
A scheduled query can inspect an Iceberg table’s files metadata view, count active data and delete files below a target size, and trigger maintenance when fragmentation exceeds a predefined limit. This avoids spending resources when the table is already well organized. section 11.1.2
Figure 11.2 By using conditional logic based on data in the metadata tables (such as the size of files in a table’s current snapshot), we can avoid running maintenance work when the table doesn’t need it.
Use the conditional workflow diagram to see how metadata state can determine whether maintenance work runs. section 11.1.2
