diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-09 18:49:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-09 18:49:55 +0000 |
commit | 85d72f05167b87bc44464b2eabea8538f1fd1e45 (patch) | |
tree | fc7af5457fa0611971618803ffa6f47396d3a183 /src/backend/access | |
parent | 7063c46fc18e2987b655b0bc7531128633daac7e (diff) | |
download | postgresql-85d72f05167b87bc44464b2eabea8538f1fd1e45.tar.gz postgresql-85d72f05167b87bc44464b2eabea8538f1fd1e45.zip |
Teach heapam code to know the difference between a real seqscan and the
pseudo HeapScanDesc created for a bitmap heap scan. This avoids some useless
overhead during a bitmap scan startup, in particular invoking the syncscan
code. (We might someday want to do that, but right now it's merely useless
contention for shared memory, to say nothing of possibly pushing useful
entries out of syncscan's small LRU list.) This also allows elimination of
ugly pgstat_discount_heap_scan() kluge.
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/heap/heapam.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index a0b561c209e..2c9dc9a949c 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.235 2007/06/08 18:23:52 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.236 2007/06/09 18:49:54 tgl Exp $ * * * INTERFACE ROUTINES @@ -58,6 +58,10 @@ #include "utils/syscache.h" +static HeapScanDesc heap_beginscan_internal(Relation relation, + Snapshot snapshot, + int nkeys, ScanKey key, + bool is_bitmapscan); static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, Buffer newbuf, HeapTuple newtup, bool move); @@ -95,8 +99,9 @@ initscan(HeapScanDesc scan, ScanKey key) * * During a rescan, don't make a new strategy object if we don't have to. */ - if (scan->rs_nblocks > NBuffers / 4 && - !scan->rs_rd->rd_istemp) + if (!scan->rs_bitmapscan && + !scan->rs_rd->rd_istemp && + scan->rs_nblocks > NBuffers / 4) { if (scan->rs_strategy == NULL) scan->rs_strategy = GetAccessStrategy(BAS_BULKREAD); @@ -114,8 +119,6 @@ initscan(HeapScanDesc scan, ScanKey key) scan->rs_startblock = 0; } - /* rs_pageatatime was set when the snapshot was filled in */ - scan->rs_inited = false; scan->rs_ctup.t_data = NULL; ItemPointerSetInvalid(&scan->rs_ctup.t_self); @@ -133,7 +136,12 @@ initscan(HeapScanDesc scan, ScanKey key) if (key != NULL) memcpy(scan->rs_key, key, scan->rs_nkeys * sizeof(ScanKeyData)); - pgstat_count_heap_scan(scan->rs_rd); + /* + * Currently, we don't have a stats counter for bitmap heap scans + * (but the underlying bitmap index scans will be counted). + */ + if (!scan->rs_bitmapscan) + pgstat_count_heap_scan(scan->rs_rd); } /* @@ -1037,12 +1045,31 @@ heap_openrv(const RangeVar *relation, LOCKMODE lockmode) /* ---------------- * heap_beginscan - begin relation scan + * + * heap_beginscan_bm is an alternate entry point for setting up a HeapScanDesc + * for a bitmap heap scan. Although that scan technology is really quite + * unlike a standard seqscan, there is just enough commonality to make it + * worth using the same data structure. * ---------------- */ HeapScanDesc heap_beginscan(Relation relation, Snapshot snapshot, int nkeys, ScanKey key) { + return heap_beginscan_internal(relation, snapshot, nkeys, key, false); +} + +HeapScanDesc +heap_beginscan_bm(Relation relation, Snapshot snapshot, + int nkeys, ScanKey key) +{ + return heap_beginscan_internal(relation, snapshot, nkeys, key, true); +} + +static HeapScanDesc +heap_beginscan_internal(Relation relation, Snapshot snapshot, + int nkeys, ScanKey key, bool is_bitmapscan) +{ HeapScanDesc scan; /* @@ -1062,6 +1089,7 @@ heap_beginscan(Relation relation, Snapshot snapshot, scan->rs_rd = relation; scan->rs_snapshot = snapshot; scan->rs_nkeys = nkeys; + scan->rs_bitmapscan = is_bitmapscan; scan->rs_strategy = NULL; /* set in initscan */ /* |