From d4cef0aa2a55fafbd9ce2783c1eb9e0157c6781e Mon Sep 17 00:00:00 2001
From: Alvaro Herrera
Date: Mon, 10 Jul 2006 16:20:52 +0000
Subject: Improve vacuum code to track minimum Xids per table instead of per
database. To this end, add a couple of columns to pg_class, relminxid and
relvacuumxid, based on which we calculate the pg_database columns after each
vacuum.
We now force all databases to be vacuumed, even template ones. A backend
noticing too old a database (meaning pg_database.datminxid is in danger of
falling behind Xid wraparound) will signal the postmaster, which in turn will
start an autovacuum iteration to process the offending database. In principle
this is only there to cope with frozen (non-connectable) databases without
forcing users to set them to connectable, but it could force regular user
database to go through a database-wide vacuum at any time. Maybe we should
warn users about this somehow. Of course the real solution will be to use
autovacuum all the time ;-)
There are some additional improvements we could have in this area: for example
the vacuum code could be smarter about not updating pg_database for each table
when called by autovacuum, and do it only once the whole autovacuum iteration
is done.
I updated the system catalogs documentation, but I didn't modify the
maintenance section. Also having some regression tests for this would be nice
but it's not really a very straightforward thing to do.
Catalog version bumped due to system catalog changes.
---
doc/src/sgml/catalogs.sgml | 44 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 37 insertions(+), 7 deletions(-)
(limited to 'doc/src')
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index cd3789f4ed2..cc42c5906ff 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1,4 +1,4 @@
-
+
@@ -1639,6 +1639,30 @@
True if table has (or once had) any inheritance children
+
+ relminxid
+ xid
+
+
+ The minimum transaction ID present in all rows in this table. This
+ value is used to determine the database-global
+ pg_database>.datminxid> value.
+
+
+
+
+ relvacuumxid
+ xid
+
+
+ The transaction ID that was used as cleaning point as of the last vacuum
+ operation. All rows inserted, updated or deleted in this table by
+ transactions whose IDs are below this one have been marked as known good
+ or deleted. This is used to determine the database-global
+ pg_database>.datvacuumxid> value.
+
+
+
relacl
aclitem[]
@@ -2022,21 +2046,27 @@
xid
- All rows inserted or deleted by transaction IDs before this one
- have been marked as known committed or known aborted in this database.
- This is used to determine when commit-log space can be recycled.
+ The transaction ID that was used as cleaning point as of the last vacuum
+ operation. All rows inserted or deleted by transaction IDs before this one
+ have been marked as known good or deleted. This
+ is used to determine when commit-log space can be recycled.
+ If InvalidTransactionId, then the minimum is unknown and can be
+ determined by scanning pg_class>.relvacuumxid>.
- datfrozenxid
+ datminxid
xid
+ The minimum transaction ID present in all tables in this database.
All rows inserted by transaction IDs before this one have been
relabeled with a permanent (frozen>) transaction ID in this
- database. This is useful to check whether a database must be vacuumed
- soon to avoid transaction ID wrap-around problems.
+ database. This is useful to check whether a database must be
+ vacuumed soon to avoid transaction ID wrap-around problems.
+ If InvalidTransactionId, then the minimum is unknown and can be
+ determined by scanning pg_class>.relminxid>.
--
cgit v1.2.3