mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Change the format of the VM fork to add a second bit per page.
The new bit indicates whether every tuple on the page is already frozen. It is cleared only when the all-visible bit is cleared, and it can be set only when we vacuum a page and find that every tuple on that page is both visible to every transaction and in no need of any future vacuuming. A future commit will use this new bit to optimize away full-table scans that would otherwise be triggered by XID wraparound considerations. A page which is merely all-visible must still be scanned in that case, but a page which is all-frozen need not be. This commit does not attempt that optimization, although that optimization is the goal here. It seems better to get the basic infrastructure in place first. Per discussion, it's very desirable for pg_upgrade to automatically migrate existing VM forks from the old format to the new format. That, too, will be handled in a follow-on patch. Masahiko Sawada, reviewed by Kyotaro Horiguchi, Fujii Masao, Amit Kapila, Simon Riggs, Andres Freund, and others, and substantially revised by me.
This commit is contained in:
@ -623,7 +623,8 @@ can be used to examine the information stored in free space maps.
|
||||
<para>
|
||||
Each heap relation has a Visibility Map
|
||||
(VM) to keep track of which pages contain only tuples that are known to be
|
||||
visible to all active transactions. It's stored
|
||||
visible to all active transactions; it also keeps track of which pages contain
|
||||
only unfrozen tuples. It's stored
|
||||
alongside the main relation data in a separate relation fork, named after the
|
||||
filenode number of the relation, plus a <literal>_vm</> suffix. For example,
|
||||
if the filenode of a relation is 12345, the VM is stored in a file called
|
||||
@ -632,11 +633,12 @@ Note that indexes do not have VMs.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The visibility map simply stores one bit per heap page. A set bit means
|
||||
that all tuples on the page are known to be visible to all transactions.
|
||||
This means that the page does not contain any tuples that need to be vacuumed.
|
||||
The visibility map stores two bits per heap page. The first bit, if set,
|
||||
indicates that the page is all-visible, or in other words that the page does
|
||||
not contain any tuples that need to be vacuumed.
|
||||
This information can also be used by <firstterm>index-only scans</> to answer
|
||||
queries using only the index tuple.
|
||||
The second bit, if set, means that all tuples on the page have been frozen.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user