Skip to content
Snippets Groups Projects
Commit 5d1dd2bc authored by Neil Conway's avatar Neil Conway
Browse files

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.
parent a51e54cf
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment