From the above output, we can also determine if the auto vacuum is running properly or not i.e… When the last auto vacuum ran on any particular table whose dead tuples are high.

Over time, due to MVCC, your table will grow in size (called table bloat)—this is why regular VACUUM is needed. This query will show you a list of tables and indexes with the most bloats. The value represents the number of “wasted bytes," or the difference between what is actually used by the table and index, and what we compute that it should be.

The way it works is it estimates the optimized size of the table/index by a calculation from each row sizes times total rows and compares that against the actual table size. Do note that this is an estimate, not an actual figure.

#postgresql #query

Useful PostgreSQL Commands/Queries
1.40 GEEK