After a recent question regarding tracking vacuum start_time in pg_stat_all_tables [1], it dawned on me that this view is missing an important cumulative metric, which is how much time is spent performing vacuum per table.
Currently, the only way a user can get this information is if they enable autovacuum logging or track timing for manual vacuums. Even then, if a user wants to trend the time spent vacuuming over time, they must store the timing data somewhere and perform the calculations.
Also, unless autovacuum logging is enabled for all a/v operations, they could have gaps in their analysis.
Having the total (auto)vacuum elapsed time along side the existing (auto)vaccum_count allows a user to track the average time an operating overtime and to find vacuum tuning opportunities.
The same can also be said for (auto)analyze.
attached a patch ( without doc changes) that adds 4 new columns:
It should be noted that the timing is only tracked when the vacuum or analyze operation completes, as is the case with the other metrics.
Also, there is another discussion in-flight [2] regarding tracking vacuum run history in a view, but this serves a different purpose as this will provide all the metrics that are other wise exposed in vacuum logging via sql. This history will also be required to drop entries using some criteria to keep the cache from growing infinitely.