1

I'm trying to understand what the below parameters mean: max_dead_tuples / num_dead_tuples on the pg_stat_progress_vacuum view.

From the Postgres documentation:

max_dead_tuples bigint Number of dead tuples that we can store before needing to perform an index vacuum cycle, based on maintenance_work_mem.

num_dead_tuples bigint Number of dead tuples collected since the last index vacuum cycle.

Does this mean this value is changed per the maintenance_work_mem allocations? I have tried setting different values to this parameter and the number on max_dead_tuples increased to 178956970 and does not move further. Even if I reduce the maintenance_work_mem this counter stays the same. Why is that so? What does these two parameter indicate?

Edit:

Noticed that when I reset the stats using select pg_stat_reset(); after changing maintenance_work_mem, I see different values in max_dead_tuples. But I don't understand why the values are inconsistent?

Please advise.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
RMu
  • 817
  • 2
  • 17
  • 41

1 Answers1

2

VACUUM proceeds like this:

  1. it scans the table until it has found as many dead tuples as fit into autovacuum_work_mem (which defaults to maintenance_work_mem). max_dead_tuples is PostgreSQL's estimate how many tuples will fit in autovacuum_work_mem.

  2. It scans all indexes and removes entries pointing to those dead tuples.

These two steps are repeated until the whole table is processed. num_dead_tuples are the number of dead tuples already found in the current iteration.

As far as I know, changing maintenance_work_mem doesn't influence an already running VACUUM, but I may be wrong.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263