1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

pgstattuple: Use a BufferAccessStrategy object to avoid cache-trashing.

Jaime Casanova, reviewed by Noah Misch, slightly modified by me.
This commit is contained in:
Robert Haas
2012-03-13 09:51:03 -04:00
parent 97c85098de
commit 2e46bf6711
2 changed files with 32 additions and 15 deletions

View File

@ -95,6 +95,7 @@ pgstatindex(PG_FUNCTION_ARGS)
BlockNumber nblocks;
BlockNumber blkno;
BTIndexStat indexStat;
BufferAccessStrategy bstrategy = GetAccessStrategy(BAS_BULKREAD);
if (!superuser())
ereport(ERROR,
@ -122,7 +123,7 @@ pgstatindex(PG_FUNCTION_ARGS)
* Read metapage
*/
{
Buffer buffer = ReadBuffer(rel, 0);
Buffer buffer = ReadBufferExtended(rel, MAIN_FORKNUM, 0, RBM_NORMAL, bstrategy);
Page page = BufferGetPage(buffer);
BTMetaPageData *metad = BTPageGetMeta(page);
@ -159,7 +160,7 @@ pgstatindex(PG_FUNCTION_ARGS)
CHECK_FOR_INTERRUPTS();
/* Read and lock buffer */
buffer = ReadBuffer(rel, blkno);
buffer = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, bstrategy);
LockBuffer(buffer, BUFFER_LOCK_SHARE);
page = BufferGetPage(buffer);