Tune autovacuum per table, not globally
The default triggers a vacuum when 20 percent of a table changed. On a 100 million row table that is 20 million dead rows before anything happens, and the table doubles in size in between.
ALTER TABLE events SET (
autovacuum_vacuum_scale_factor = 0.01,
autovacuum_vacuum_cost_delay = 2
);One percent on the hot tables, defaults everywhere else. Watch n_dead_tup in pg_stat_user_tables to find the tables that need it.
postgresqloperations