Does restarting Postgres cause dead tuples to get removed?
Context:
I have a relation that contains many wide fields and Postgres is storing the values out of line in a toast table. When doing so it generates references as OIds that point to the values in the toast table.
Generating OIds can be slow as Postgres will try will make sure oids do not collide as there is an upper limit of how many of them it can generate.
My relation has a very low row count (around 20) but it gets updated very frequently. This of course leads to a big number of dead tuples.
When I restarted Postgres, the slowness disappeared. So I had a hypothesis that says dead tuples are removed when restarting Postgres.
SELECT relname AS TableName
, n_live_tup AS LiveTuples
, n_dead_tup AS DeadTuples
FROM pg_stat_user_tables;
I launched this query before and after the restart. The number of live and dead tuples went from X to 0.
Is this enough to validate the hypothesis?