summaryrefslogtreecommitdiff
path: root/src/include/utils/tqual.h
diff options
context:
space:
mode:
authorTom Lane2005-11-26 03:03:07 +0000
committerTom Lane2005-11-26 03:03:07 +0000
commit70f1482de3dd797eeee6093210c716115c38795b (patch)
tree781172ccd2c151515682c6157a89758bee73d021 /src/include/utils/tqual.h
parent290166f93404d8759f4bf60ef1732c8ba9a52785 (diff)
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/utils/tqual.h')
-rw-r--r--src/include/utils/tqual.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h
index bfd51cb72e6..5e3efa17967 100644
--- a/src/include/utils/tqual.h
+++ b/src/include/utils/tqual.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.59 2005/10/15 02:49:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.60 2005/11/26 03:03:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -55,6 +55,15 @@ typedef SnapshotData *Snapshot;
extern DLLIMPORT Snapshot SnapshotDirty;
+/* This macro encodes the knowledge of which snapshots are MVCC-safe */
+#define IsMVCCSnapshot(snapshot) \
+ ((snapshot) != SnapshotNow && \
+ (snapshot) != SnapshotSelf && \
+ (snapshot) != SnapshotAny && \
+ (snapshot) != SnapshotToast && \
+ (snapshot) != SnapshotDirty)
+
+
extern DLLIMPORT Snapshot SerializableSnapshot;
extern DLLIMPORT Snapshot LatestSnapshot;
extern DLLIMPORT Snapshot ActiveSnapshot;
@@ -69,8 +78,9 @@ extern TransactionId RecentGlobalXmin;
* True iff heap tuple satisfies a time qual.
*
* Notes:
- * Assumes heap tuple is valid.
- * Beware of multiple evaluations of snapshot argument.
+ * Assumes heap tuple is valid.
+ * Beware of multiple evaluations of snapshot argument.
+ * Hint bits in the HeapTuple's t_infomask may be updated as a side effect.
*/
#define HeapTupleSatisfiesVisibility(tuple, snapshot, buffer) \
((snapshot) == SnapshotNow ? \