mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Arrange to cache btree metapage data in the relcache entry for the index,
thereby saving a visit to the metapage in most index searches/updates. This wouldn't actually save any I/O (since in the old regime the metapage generally stayed in cache anyway), but it does provide a useful decrease in bufmgr traffic in high-contention scenarios. Per my recent proposal.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.135 2006/04/13 03:53:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.136 2006/04/25 22:46:05 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "access/heapam.h"
|
||||
#include "access/nbtree.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/inval.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
@@ -638,9 +639,12 @@ _bt_insertonpg(Relation rel,
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
||||
/* release pin/lock */
|
||||
/* release buffers; send out relcache inval if metapage changed */
|
||||
if (BufferIsValid(metabuf))
|
||||
{
|
||||
CacheInvalidateRelcache(rel);
|
||||
_bt_relbuf(rel, metabuf);
|
||||
}
|
||||
|
||||
_bt_relbuf(rel, buf);
|
||||
}
|
||||
@@ -1526,6 +1530,9 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
||||
/* send out relcache inval for metapage change */
|
||||
CacheInvalidateRelcache(rel);
|
||||
|
||||
/* done with metapage */
|
||||
_bt_relbuf(rel, metabuf);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user