mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Introduce visibility map. The visibility map is a bitmap with one bit per
heap page, where a set bit indicates that all tuples on the page are visible to all transactions, and the page therefore doesn't need vacuuming. It is stored in a new relation fork. Lazy vacuum uses the visibility map to skip pages that don't need vacuuming. Vacuum is also responsible for setting the bits in the map. In the future, this can hopefully be used to implement index-only-scans, but we can't currently guarantee that the visibility map is always 100% up-to-date. In addition to the visibility map, there's a new PD_ALL_VISIBLE flag on each heap page, also indicating that all tuples on the page are visible to all transactions. It's important that this flag is kept up-to-date. It is also used to skip visibility tests in sequential scans, which gives a small performance gain on seqscans.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.84 2008/11/03 20:47:49 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.85 2008/12/03 13:05:22 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -152,8 +152,10 @@ typedef PageHeaderData *PageHeader;
|
||||
#define PD_HAS_FREE_LINES 0x0001 /* are there any unused line pointers? */
|
||||
#define PD_PAGE_FULL 0x0002 /* not enough free space for new
|
||||
* tuple? */
|
||||
#define PD_ALL_VISIBLE 0x0004 /* all tuples on page are visible to
|
||||
* everyone */
|
||||
|
||||
#define PD_VALID_FLAG_BITS 0x0003 /* OR of all valid pd_flags bits */
|
||||
#define PD_VALID_FLAG_BITS 0x0007 /* OR of all valid pd_flags bits */
|
||||
|
||||
/*
|
||||
* Page layout version number 0 is for pre-7.3 Postgres releases.
|
||||
@@ -336,6 +338,13 @@ typedef PageHeaderData *PageHeader;
|
||||
#define PageClearFull(page) \
|
||||
(((PageHeader) (page))->pd_flags &= ~PD_PAGE_FULL)
|
||||
|
||||
#define PageIsAllVisible(page) \
|
||||
(((PageHeader) (page))->pd_flags & PD_ALL_VISIBLE)
|
||||
#define PageSetAllVisible(page) \
|
||||
(((PageHeader) (page))->pd_flags |= PD_ALL_VISIBLE)
|
||||
#define PageClearAllVisible(page) \
|
||||
(((PageHeader) (page))->pd_flags &= ~PD_ALL_VISIBLE)
|
||||
|
||||
#define PageIsPrunable(page, oldestxmin) \
|
||||
( \
|
||||
AssertMacro(TransactionIdIsNormal(oldestxmin)), \
|
||||
|
||||
Reference in New Issue
Block a user