From eee71cdfdaff3295d52c1213d47ec1754e87a1f8 Mon Sep 17 00:00:00 2001 From: Sami Imseih Date: Tue, 10 Mar 2026 19:04:03 -0500 Subject: [PATCH v1 1/1] autovacuum scheduling improvements - docs --- doc/src/sgml/maintenance.sgml | 95 +++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index 7c958b06273..16b50f8e5b6 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -1054,6 +1054,99 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu not automatically interrupted. + + Processing Priority + + + Autovacuum decides what to process in two steps: first it picks a + database, then it orders the tables within that database. + + + + The launcher first checks for databases at risk of wraparound, + with transaction ID wraparound taking precedence over multixact + wraparound. If no database is at risk, the least recently + auto-vacuumed database is selected. Databases that have never been + connected to, or that have had no activity since the statistics were + last reset, are not considered except when at risk of wraparound. + + + + Within a database, the autovacuum worker builds a list of all tables + that need vacuuming or analyzing and sorts them by a + priority score. Tables with higher scores are + processed first. + + + + The score for each table is calculated as the maximum of several + component scores, each representing how far the table has exceeded a + particular threshold. Each component is multiplied by a configurable + weight parameter: + + + + + : the ratio of + dead tuples to the table's vacuum threshold. For example, if a table + has 100 dead tuples and its vacuum threshold is 80, this component's + score is 1.25. + + + + + : the ratio + of inserted tuples (since the last vacuum) to the table's insert + vacuum threshold. + + + + + : the ratio of + modified tuples (since the last analyze) to the table's analyze + threshold. + + + + + : the ratio of + the table's transaction ID age + (relfrozenxid) to + . This component is + only considered for tables that have already exceeded their freeze max + age. + + + + + : the + ratio of the table's multixact age + (relminmxid) to + . Like the + freeze score, this is only considered for tables past their multixact + freeze max age. + + + + + The final score is the maximum of these weighted components. + + + + Tables that are approaching transaction ID or multixact wraparound receive + additional priority. Once a table's age surpasses + or + , its freeze score is + scaled aggressively so that it sorts toward the top of the list. + + + + All weights default to 1.0. Reducing a weight to a value below 1.0 + decreases the influence of that component on the final score, making + tables that exceed that particular threshold less likely to be processed + first. + + Regularly running commands that acquire locks conflicting with a @@ -1061,6 +1154,8 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu effectively prevent autovacuums from ever completing. + + -- 2.50.1 (Apple Git-155)