mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +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/access/htup.h,v 1.104 2008/11/14 01:57:42 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.105 2008/12/03 13:05:22 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -601,9 +601,10 @@ typedef struct xl_heaptid
|
||||
typedef struct xl_heap_delete
|
||||
{
|
||||
xl_heaptid target; /* deleted tuple id */
|
||||
bool all_visible_cleared; /* PD_ALL_VISIBLE was cleared */
|
||||
} xl_heap_delete;
|
||||
|
||||
#define SizeOfHeapDelete (offsetof(xl_heap_delete, target) + SizeOfHeapTid)
|
||||
#define SizeOfHeapDelete (offsetof(xl_heap_delete, all_visible_cleared) + sizeof(bool))
|
||||
|
||||
/*
|
||||
* We don't store the whole fixed part (HeapTupleHeaderData) of an inserted
|
||||
@@ -626,21 +627,24 @@ typedef struct xl_heap_header
|
||||
typedef struct xl_heap_insert
|
||||
{
|
||||
xl_heaptid target; /* inserted tuple id */
|
||||
bool all_visible_cleared; /* PD_ALL_VISIBLE was cleared */
|
||||
/* xl_heap_header & TUPLE DATA FOLLOWS AT END OF STRUCT */
|
||||
} xl_heap_insert;
|
||||
|
||||
#define SizeOfHeapInsert (offsetof(xl_heap_insert, target) + SizeOfHeapTid)
|
||||
#define SizeOfHeapInsert (offsetof(xl_heap_insert, all_visible_cleared) + sizeof(bool))
|
||||
|
||||
/* This is what we need to know about update|move|hot_update */
|
||||
typedef struct xl_heap_update
|
||||
{
|
||||
xl_heaptid target; /* deleted tuple id */
|
||||
ItemPointerData newtid; /* new inserted tuple id */
|
||||
bool all_visible_cleared; /* PD_ALL_VISIBLE was cleared */
|
||||
bool new_all_visible_cleared; /* same for the page of newtid */
|
||||
/* NEW TUPLE xl_heap_header (PLUS xmax & xmin IF MOVE OP) */
|
||||
/* and TUPLE DATA FOLLOWS AT END OF STRUCT */
|
||||
} xl_heap_update;
|
||||
|
||||
#define SizeOfHeapUpdate (offsetof(xl_heap_update, newtid) + SizeOfIptrData)
|
||||
#define SizeOfHeapUpdate (offsetof(xl_heap_update, new_all_visible_cleared) + sizeof(bool))
|
||||
|
||||
/*
|
||||
* This is what we need to know about vacuum page cleanup/redirect
|
||||
|
||||
Reference in New Issue
Block a user