If I understand correctly, under MVCC(multi version concurrency control), dead tuples are left in the page, until the Vacuum comes in and mark them "unused", and until "vacuum full" comes in and reorgnize them to defragment the space -- so we use less space for the same data.
I have a table, which in one environment that hasn't done vacuum full
has around:
SELECT relpages, reltuples from pg_class where relname='pg_toast_16450';
relpages | reltuples
-----------+--------------
544447814 | 6.394397e+06
In another environment that has undergone vacuum full
has:
SELECT relpages, reltuples from pg_class where relname='pg_toast_16450';
relpages | reltuples
----------+--------------
2476625 | 4.439228e+06
Looks like relpages
does lower dramatically, which matches my understanding. However, reltuples
does not. (relpages has a 250X change, yet reltuples has just 1.33X) Does that mean reltuples
does not include dead tuples? If that's the case, does the query planner utilizing reltuples
to design query plan has a way around dead tuples?