I am trying to find the number of vacuum-eligible tuples in one of our postgres tables. This is the output of vacuum verbose on that table

INFO:  "act_msgs": found 0 removable, 2217083 nonremovable row     versions in 314492 out of 314492 pages
DETAIL:  2185476 dead row versions cannot be removed yet.
There were 62133 unused item pointers.

Before running the vacuum the live and dead tuple counts were n_live_tup => 2204051 and n_dead_tup => 12370. After running the vacuum they are n_live_tup => 2217220 and n_dead_tup => 9. So it looks like if vacuum cannot remove the actually deleted tuples it adds those tuples to live_tup.

Now, we know that we have a long running transaction opened by the application and that is causing the auto vacuum not able to clean up the dead tuples. The application would do frequent inserts and deletes. How do i find the number of tuples that were actually deleted and would be vacuumed when that transaction is closed?

1 Answer 1


It clearly tells you right there..

DETAIL: 2185476 dead row versions cannot be removed yet.

That's how many versions are vacuum-eligible. They're not being vacuumed because you have a long running transaction holding a ACCESS SHARE lock on the table?

See this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.