summaryrefslogtreecommitdiff
path: root/src/include/access/relscan.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-11-26 03:03:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-11-26 03:03:07 +0000
commit70f1482de3dd797eeee6093210c716115c38795b (patch)
tree781172ccd2c151515682c6157a89758bee73d021 /src/include/access/relscan.h
parent290166f93404d8759f4bf60ef1732c8ba9a52785 (diff)
downloadpostgresql-70f1482de3dd797eeee6093210c716115c38795b.tar.gz
Change seqscan logic so that we check visibility of all tuples on a page
when we first read the page, rather than checking them one at a time. This allows us to take and release the buffer content lock just once per page, instead of once per tuple. Since it's a shared lock the contention penalty for holding the lock longer shouldn't be too bad. We can safely do this only when using an MVCC snapshot; else the assumption that visibility won't change over time is uncool. Therefore there are now two code paths depending on the snapshot type. I also made the same change in nodeBitmapHeapscan.c, where it can be done always because we only support MVCC snapshots for bitmap scans anyway. Also make some incidental cleanups in the APIs of these functions. Per a suggestion from Qingqing Zhou.
Diffstat (limited to 'src/include/access/relscan.h')
-rw-r--r--src/include/access/relscan.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h
index 88f4078d24..c0b7c92cd5 100644
--- a/src/include/access/relscan.h
+++ b/src/include/access/relscan.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.41 2005/10/15 02:49:42 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.42 2005/11/26 03:03:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,14 +26,23 @@ typedef struct HeapScanDescData
int rs_nkeys; /* number of scan keys */
ScanKey rs_key; /* array of scan key descriptors */
BlockNumber rs_nblocks; /* number of blocks to scan */
+ bool rs_pageatatime; /* verify visibility page-at-a-time? */
/* scan current state */
+ bool rs_inited; /* false = scan not init'd yet */
HeapTupleData rs_ctup; /* current tuple in scan, if any */
+ BlockNumber rs_cblock; /* current block # in scan, if any */
Buffer rs_cbuf; /* current buffer in scan, if any */
/* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
ItemPointerData rs_mctid; /* marked scan position, if any */
PgStat_Info rs_pgstat_info; /* statistics collector hook */
+
+ /* these fields only used in page-at-a-time mode */
+ int rs_cindex; /* current tuple's index in vistuples */
+ int rs_mindex; /* marked tuple's saved index */
+ int rs_ntuples; /* number of visible tuples on page */
+ OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]; /* their offsets */
} HeapScanDescData;
typedef HeapScanDescData *HeapScanDesc;