Runbook
PostgreSQL database bloat due to accumulated dead tuples
Back to Runbooks
Overview
This incident type involves the accumulation of dead tuples in a database due to
UPDATE
and DELETE
activity, which can lead to bloat in both tables and indexes. Bloat is characterized by the accumulation of dead tuples that cause gaps in the physical layout, leading to excessive disk space usage and performance degradation. While VACUUM FULL
is a standard command that can be used to get rid of bloat, it uses a long-lasting exclusive lock on the table, which can impact performance by blocking all queries to the table. Pg_repack uses a more graceful approach that requires short-lived locks, making it suitable for databases with high and concurrent activity.Parameters
Debug
Check if the database is running
Check the size of the database
Check the amount of dead tuples
Check for index bloat
Check if autovacuum is enabled
Check if VACUUM FULL was run previously
Check for table and index bloat using pg_repack
Check for pg_repack errors
Repair
Regularly monitor database tables and indexes for bloat using tools like pgstattuple and pg_repack.
Use VACUUM FULL or pg_repack to reclaim disk space and improve performance, but schedule these operations during low traffic periods to minimize impact on queries.
Optimize SQL queries to reduce the number of UPDATE and DELETE operations and minimize the accumulation of dead tuples.
Learn more
Related Runbooks
Check out these related runbooks to help you debug and resolve similar issues.