summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2007-06-08 18:23:53 +0000
committerTom Lane2007-06-08 18:23:53 +0000
commita04a423599b347325f9a73dfb2d533b24e1cbab3 (patch)
tree5aeb620900a705222eb202c7b4b1d33266d1c190 /src/include
parent6d6d14b6d52f7a709fba8fd23244a7de014f2048 (diff)
Arrange for large sequential scans to synchronize with each other, so that
when multiple backends are scanning the same relation concurrently, each page is (ideally) read only once. Jeff Davis, with review by Heikki and Tom.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/heapam.h24
-rw-r--r--src/include/access/relscan.h6
-rw-r--r--src/include/pg_config_manual.h7
-rw-r--r--src/include/storage/lwlock.h3
4 files changed, 28 insertions, 12 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index ebb2e984c24..206159bdad7 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.124 2007/05/27 03:50:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.125 2007/06/08 18:23:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -112,6 +112,13 @@ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
)
+typedef enum
+{
+ LockTupleShared,
+ LockTupleExclusive
+} LockTupleMode;
+
+
/* ----------------
* function prototypes for heap access method
*
@@ -120,14 +127,7 @@ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
* ----------------
*/
-/* heapam.c */
-
-typedef enum
-{
- LockTupleShared,
- LockTupleExclusive
-} LockTupleMode;
-
+/* in heap/heapam.c */
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
extern Relation relation_open_nowait(Oid relationId, LOCKMODE lockmode);
@@ -240,4 +240,10 @@ extern HeapTuple heap_addheader(int natts, bool withoid,
extern void heap_sync(Relation relation);
+/* in heap/syncscan.c */
+extern void ss_report_location(Relation rel, BlockNumber location);
+extern BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks);
+extern void SyncScanShmemInit(void);
+extern Size SyncScanShmemSize(void);
+
#endif /* HEAPAM_H */
diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h
index 200b45713e7..b45b2caabf1 100644
--- a/src/include/access/relscan.h
+++ b/src/include/access/relscan.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.54 2007/05/30 20:12:02 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.55 2007/06/08 18:23:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,9 +26,13 @@ typedef struct HeapScanDescData
Snapshot rs_snapshot; /* snapshot to see */
int rs_nkeys; /* number of scan keys */
ScanKey rs_key; /* array of scan key descriptors */
+
+ /* state set up at initscan time */
BlockNumber rs_nblocks; /* number of blocks to scan */
+ BlockNumber rs_startblock; /* block # to start at */
BufferAccessStrategy rs_strategy; /* access strategy for reads */
bool rs_pageatatime; /* verify visibility page-at-a-time? */
+ bool rs_syncscan; /* report location to syncscan logic? */
/* scan current state */
bool rs_inited; /* false = scan not init'd yet */
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index a5b3f98a8eb..354a3d370eb 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -6,7 +6,7 @@
* for developers. If you edit any of these, be sure to do a *full*
* rebuild (and an initdb if noted).
*
- * $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.26 2007/02/23 21:36:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.27 2007/06/08 18:23:53 tgl Exp $
*------------------------------------------------------------------------
*/
@@ -250,6 +250,11 @@
#define TRACE_SORT 1
/*
+ * Enable tracing of syncscan operations (see also the trace_syncscan GUC var).
+ */
+/* #define TRACE_SYNCSCAN */
+
+/*
* Other debug #defines (documentation, anyone?)
*/
/* #define HEAPDEBUGALL */
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index 477284b7d1d..046064cdc1f 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.36 2007/04/16 18:30:04 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.37 2007/06/08 18:23:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -62,6 +62,7 @@ typedef enum LWLockId
AddinShmemInitLock,
AutovacuumLock,
AutovacuumScheduleLock,
+ SyncScanLock,
/* Individual lock IDs end here */
FirstBufMappingLock,
FirstLockMgrLock = FirstBufMappingLock + NUM_BUFFER_PARTITIONS,