Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5d1dd2b

Browse files
author
Neil Conway
committed
Micro-optimization of markpos() and restrpos() in btree and hash indexes.
Rather than using ReadBuffer() to increment the reference count on analready-pinned buffer, we should use IncrBufferRefCount() as it isfaster and does not require acquiring the BufMgrLock.
1 parenta51e54c commit5d1dd2b

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

‎src/backend/access/hash/hash.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.74 2004/11/11 00:32:40 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.75 2004/11/17 03:13:37 neilc Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -397,9 +397,8 @@ hashmarkpos(PG_FUNCTION_ARGS)
397397
/* bump pin count on currentItemData and copy to currentMarkData */
398398
if (ItemPointerIsValid(&(scan->currentItemData)))
399399
{
400-
so->hashso_mrkbuf=_hash_getbuf(rel,
401-
BufferGetBlockNumber(so->hashso_curbuf),
402-
HASH_NOLOCK);
400+
IncrBufferRefCount(so->hashso_curbuf);
401+
so->hashso_mrkbuf=so->hashso_curbuf;
403402
scan->currentMarkData=scan->currentItemData;
404403
}
405404

@@ -425,9 +424,8 @@ hashrestrpos(PG_FUNCTION_ARGS)
425424
/* bump pin count on currentMarkData and copy to currentItemData */
426425
if (ItemPointerIsValid(&(scan->currentMarkData)))
427426
{
428-
so->hashso_curbuf=_hash_getbuf(rel,
429-
BufferGetBlockNumber(so->hashso_mrkbuf),
430-
HASH_NOLOCK);
427+
IncrBufferRefCount(so->hashso_mrkbuf);
428+
so->hashso_curbuf=so->hashso_mrkbuf;
431429
scan->currentItemData=scan->currentMarkData;
432430
}
433431

‎src/backend/access/nbtree/nbtree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.121 2004/11/11 00:32:50 neilc Exp $
15+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.122 2004/11/17 03:13:38 neilc Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -477,8 +477,8 @@ btmarkpos(PG_FUNCTION_ARGS)
477477
/* bump pin on current buffer for assignment to mark buffer */
478478
if (ItemPointerIsValid(&(scan->currentItemData)))
479479
{
480-
so->btso_mrkbuf=ReadBuffer(scan->indexRelation,
481-
BufferGetBlockNumber(so->btso_curbuf));
480+
IncrBufferRefCount(so->btso_curbuf);
481+
so->btso_mrkbuf=so->btso_curbuf;
482482
scan->currentMarkData=scan->currentItemData;
483483
so->mrkHeapIptr=so->curHeapIptr;
484484
}
@@ -509,8 +509,8 @@ btrestrpos(PG_FUNCTION_ARGS)
509509
/* bump pin on marked buffer */
510510
if (ItemPointerIsValid(&(scan->currentMarkData)))
511511
{
512-
so->btso_curbuf=ReadBuffer(scan->indexRelation,
513-
BufferGetBlockNumber(so->btso_mrkbuf));
512+
IncrBufferRefCount(so->btso_mrkbuf);
513+
so->btso_curbuf=so->btso_mrkbuf;
514514
scan->currentItemData=scan->currentMarkData;
515515
so->curHeapIptr=so->mrkHeapIptr;
516516
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp