Groom tables
As part of your routine database maintenance activities, plan to recover disk space that is occupied by outdated or deleted rows. In normal operation, an update or delete of a table row does not remove the old tuple (version of the row). This approach benefits multiversion concurrency control by retaining tuples that can potentially be visible to other transactions. Over time however, the outdated or deleted tuples are of no interest to any transaction. After you capture them in a backup, you can reclaim the space that they occupy by using the SQL GROOM TABLE command.
- Groom tables that receive frequent updates or deletes more often than tables that are seldom updated.
- If you have a mixture of large tables, some of which are heavily updated and others that are seldom updated, you might want to set up periodic tasks that routinely groom the frequently updated tables.
- Grooming deleted records has no effect on your database statistics because the process physically removes records that were already “logically” deleted. When you groom a table, the system leaves the min/max, null, and estimated dispersion values unchanged.
- Reclaiming records does affect where the remaining records in the table are located. The system updates the zone map accordingly.
- If you truncated a table and there are in-flight transactions that started before the TRUNCATE query, note that the groom process does not reclaim the truncated rows until after the last in-flight transaction has committed or aborted.