Data cleanup
Cleaning up bloated tables and indexes can be done by invoking the VACUUM FULL statement for tables and REINDEX for indexes; VACUUM FULL requires exclusive lock, which means there will be an outage and the table is not accessible. There are third-party tools, such as pg_repack, which can help in solving such issues.
You can take a look at the Bucardo check_postgres Nagios plugin code at https://bucardo.org/wiki/Check_postgres to understand how bloats in tables and indexes can be calculated. Another useful contribution module is pgstattuple, which contains many functions to get statistics about tuples. Refer to https://www.postgresql.org/docs/current/pgstattuple.html.
Cleaning up data is an important topic; often, the data life ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access