This patch makes a minor optimization to the restrpos() and markpos()
implementations for btree and hash: to bump the reference count on a
buffer, it is more efficient to use IncrBufferRefCount() than to do a
ReadBuffer (for one thing we needn't acquire the BufMgrLock; we also
don't need to do a hash table lookup etc.)
Barring any objections I will apply to HEAD before end of day.
-Neil
#
# patch "src/backend/access/hash/hash.c"
# from [932df947ff5d32c4a90f7231fe30451a8a3ca21f]
# to [69c44f2b436d81702eccfd4010118ea9c14abbfd]
#
# patch "src/backend/access/nbtree/nbtree.c"
# from [a097527f8028f95b1e89eafa9fab335bc3e1e2d8]
# to [786fcf3dbe60d1fb0142aaee8b62b3422d5ee0a7]
#
--- src/backend/access/hash/hash.c
+++ src/backend/access/hash/hash.c
@@ -397,9 +397,8 @@
/* bump pin count on currentItemData and copy to currentMarkData */
if (ItemPointerIsValid(&(scan->currentItemData)))
{
- so->hashso_mrkbuf = _hash_getbuf(rel,
- BufferGetBlockNumber(so->hashso_curbuf),
- HASH_NOLOCK);
+ IncrBufferRefCount(so->hashso_curbuf);
+ so->hashso_mrkbuf = so->hashso_curbuf;
scan->currentMarkData = scan->currentItemData;
}
@@ -425,9 +424,8 @@
/* bump pin count on currentMarkData and copy to currentItemData */
if (ItemPointerIsValid(&(scan->currentMarkData)))
{
- so->hashso_curbuf = _hash_getbuf(rel,
- BufferGetBlockNumber(so->hashso_mrkbuf),
- HASH_NOLOCK);
+ IncrBufferRefCount(so->hashso_mrkbuf);
+ so->hashso_curbuf = so->hashso_mrkbuf;
scan->currentItemData = scan->currentMarkData;
}
--- src/backend/access/nbtree/nbtree.c
+++ src/backend/access/nbtree/nbtree.c
@@ -477,8 +477,8 @@
/* bump pin on current buffer for assignment to mark buffer */
if (ItemPointerIsValid(&(scan->currentItemData)))
{
- so->btso_mrkbuf = ReadBuffer(scan->indexRelation,
- BufferGetBlockNumber(so->btso_curbuf));
+ IncrBufferRefCount(so->btso_curbuf);
+ so->btso_mrkbuf = so->btso_curbuf;
scan->currentMarkData = scan->currentItemData;
so->mrkHeapIptr = so->curHeapIptr;
}
@@ -509,8 +509,8 @@
/* bump pin on marked buffer */
if (ItemPointerIsValid(&(scan->currentMarkData)))
{
- so->btso_curbuf = ReadBuffer(scan->indexRelation,
- BufferGetBlockNumber(so->btso_mrkbuf));
+ IncrBufferRefCount(so->btso_mrkbuf);
+ so->btso_curbuf = so->btso_mrkbuf;
scan->currentItemData = scan->currentMarkData;
so->curHeapIptr = so->mrkHeapIptr;
}
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match