aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-11-17 03:13:38 +0000
committerNeil Conway <neilc@samurai.com>2004-11-17 03:13:38 +0000
commit5d1dd2bc55edaf9bd4f733e835e56cabbfe310cd (patch)
tree7c5e756adbaf02329cf9f32e2b22dce44667e73f /src
parenta51e54cf5b93de5943d2a28e2c4058b5be456aeb (diff)
downloadpostgresql-5d1dd2bc55edaf9bd4f733e835e56cabbfe310cd.tar.gz
postgresql-5d1dd2bc55edaf9bd4f733e835e56cabbfe310cd.zip
Micro-optimization of markpos() and restrpos() in btree and hash indexes.
Rather than using ReadBuffer() to increment the reference count on an already-pinned buffer, we should use IncrBufferRefCount() as it is faster and does not require acquiring the BufMgrLock.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/hash/hash.c12
-rw-r--r--src/backend/access/nbtree/nbtree.c10
2 files changed, 10 insertions, 12 deletions
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 0ca2343cea4..370eba0c4ef 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.74 2004/11/11 00:32:40 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.75 2004/11/17 03:13:37 neilc Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -397,9 +397,8 @@ hashmarkpos(PG_FUNCTION_ARGS)
/* 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 @@ hashrestrpos(PG_FUNCTION_ARGS)
/* 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;
}
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 92cd0f09cec..771ff6cbe7c 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.121 2004/11/11 00:32:50 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.122 2004/11/17 03:13:38 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -477,8 +477,8 @@ btmarkpos(PG_FUNCTION_ARGS)
/* 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 @@ btrestrpos(PG_FUNCTION_ARGS)
/* 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;
}