From c1da752cc6f649d1ee4694091e12481232b569ca Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Sat, 4 Apr 2026 14:08:43 -0500 Subject: [PATCH v12 3/3] add booleans to view --- doc/src/sgml/monitoring.sgml | 43 ++++++++++++++++++++++------ src/backend/catalog/system_views.sql | 5 +++- src/backend/postmaster/autovacuum.c | 7 +++-- src/include/catalog/pg_proc.dat | 6 ++-- src/test/regress/expected/rules.out | 7 +++-- 5 files changed, 51 insertions(+), 17 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index b8b2967aa36..3888292bec3 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -4576,13 +4576,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage Maximum value of all component scores. This is the value that - autovacuum uses to sort the list of tables to process. When the - "weight" parameters are set to their default values of - 1.0, scores greater than or equal to - 1.0 indicate the table will be processed (unless - autovacuum is disabled and neither xid_score nor - mxid_score are greater than or equal to - 1.0). + autovacuum uses to sort the list of tables to process. @@ -4593,7 +4587,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage Transaction ID age component score. Scores greater than or equal to indicate the table - will be vacuumed. + will be vacuumed for transaction ID wraparound prevention. @@ -4604,7 +4598,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage Multixact ID age component score. Scores greater than or equal to indicate - the table will be vacuumed. + the table will be vacuumed for multixact ID wraparound prevention. @@ -4640,6 +4634,37 @@ description | Waiting for a newly initialized WAL file to reach durable storage will be analyzed (unless autovacuum is disabled). + + + + will_vacuum bool + + + Whether the table will be vacuumed. Note that even if the component + scores indicate that the table needs to be vacuumed, this may be + false if autovacuum is disabled. + + + + + + will_analyze bool + + + Whether the table will be analyzed. Note that even if the component + scores indicate that the table needs to be analyzed, this may be + false if autovacuum is disabled. + + + + + + for_wraparound bool + + + Whether the table will be vacuumed for wraparound prevention. + + diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 5c2f2977965..83cc3edcbeb 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -805,7 +805,10 @@ CREATE VIEW pg_stat_autovacuum_scores AS s.mxid_score, s.vacuum_score, s.vacuum_insert_score, - s.analyze_score + s.analyze_score, + s.will_vacuum, + s.will_analyze, + s.for_wraparound FROM pg_stat_get_autovacuum_scores() s JOIN pg_class c on c.oid = s.oid LEFT JOIN pg_namespace n ON n.oid = c.relnamespace; diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index c6c601dd3ad..26faa9870ba 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -3659,8 +3659,8 @@ pg_stat_get_autovacuum_scores(PG_FUNCTION_ARGS) bool doanalyze; bool wraparound; AutoVacuumScores scores; - Datum vals[7]; - bool nulls[7] = {false}; + Datum vals[10]; + bool nulls[10] = {false}; /* skip ineligible entries */ if (form->relkind != RELKIND_RELATION && @@ -3685,6 +3685,9 @@ pg_stat_get_autovacuum_scores(PG_FUNCTION_ARGS) vals[4] = Float8GetDatum(scores.vac); vals[5] = Float8GetDatum(scores.vac_ins); vals[6] = Float8GetDatum(scores.anl); + vals[7] = BoolGetDatum(dovacuum); + vals[8] = BoolGetDatum(doanalyze); + vals[9] = BoolGetDatum(wraparound); tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, vals, nulls); } diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 0de3bb52eb2..d79b4465b10 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5670,9 +5670,9 @@ { oid => '8409', descr => 'autovacuum scores', proname => 'pg_stat_get_autovacuum_scores', prorows => '100', proretset => 't', provolatile => 'v', proparallel => 'u', prorettype => 'record', proargtypes => '', - proallargtypes => '{oid,float8,float8,float8,float8,float8,float8}', - proargmodes => '{o,o,o,o,o,o,o}', - proargnames => '{oid,score,xid_score,mxid_score,vacuum_score,vacuum_insert_score,analyze_score}', + proallargtypes => '{oid,float8,float8,float8,float8,float8,float8,bool,bool,bool}', + proargmodes => '{o,o,o,o,o,o,o,o,o,o}', + proargnames => '{oid,score,xid_score,mxid_score,vacuum_score,vacuum_insert_score,analyze_score,will_vacuum,will_analyze,for_wraparound}', prosrc => 'pg_stat_get_autovacuum_scores' }, { oid => '1936', descr => 'statistics: currently active backend IDs', proname => 'pg_stat_get_backend_idset', prorows => '100', proretset => 't', diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index b167e8d3cab..d978aedbd07 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -1868,8 +1868,11 @@ pg_stat_autovacuum_scores| SELECT s.oid AS relid, s.mxid_score, s.vacuum_score, s.vacuum_insert_score, - s.analyze_score - FROM ((pg_stat_get_autovacuum_scores() s(oid, score, xid_score, mxid_score, vacuum_score, vacuum_insert_score, analyze_score) + s.analyze_score, + s.will_vacuum, + s.will_analyze, + s.for_wraparound + FROM ((pg_stat_get_autovacuum_scores() s(oid, score, xid_score, mxid_score, vacuum_score, vacuum_insert_score, analyze_score, will_vacuum, will_analyze, for_wraparound) JOIN pg_class c ON ((c.oid = s.oid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))); pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_buf_written_clean() AS buffers_clean, -- 2.50.1 (Apple Git-155)