mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.125 2006/07/03 22:45:36 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.126 2006/07/10 16:20:49 alvherre Exp $ -->
|
||||
<!--
|
||||
Documentation of the system catalogs, directed toward PostgreSQL developers
|
||||
-->
|
||||
@ -1639,6 +1639,30 @@
|
||||
<entry>True if table has (or once had) any inheritance children</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>relminxid</structfield></entry>
|
||||
<entry><type>xid</type></entry>
|
||||
<entry></entry>
|
||||
<entry>
|
||||
The minimum transaction ID present in all rows in this table. This
|
||||
value is used to determine the database-global
|
||||
<structname>pg_database</>.<structfield>datminxid</> value.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>relvacuumxid</structfield></entry>
|
||||
<entry><type>xid</type></entry>
|
||||
<entry></entry>
|
||||
<entry>
|
||||
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
|
||||
<structname>pg_database</>.<structfield>datvacuumxid</> value.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>relacl</structfield></entry>
|
||||
<entry><type>aclitem[]</type></entry>
|
||||
@ -2022,21 +2046,27 @@
|
||||
<entry><type>xid</type></entry>
|
||||
<entry></entry>
|
||||
<entry>
|
||||
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 <structname>pg_class</>.<structfield>relvacuumxid</>.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>datfrozenxid</structfield></entry>
|
||||
<entry><structfield>datminxid</structfield></entry>
|
||||
<entry><type>xid</type></entry>
|
||||
<entry></entry>
|
||||
<entry>
|
||||
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 (<quote>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 <structname>pg_class</>.<structfield>relminxid</>.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
|
Reference in New Issue
Block a user