1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Make heap_fetch API more consistent by having the buffer remain pinned

in all cases when keep_buf = true.  This allows ANALYZE's inner loop to
use heap_release_fetch, which saves multiple buffer lookups for the same
page and avoids overestimation of cost by the vacuum cost mechanism.
This commit is contained in:
Tom Lane
2004-10-26 16:05:03 +00:00
parent 2c66dcf684
commit 83cd2d8b0f
3 changed files with 31 additions and 28 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.77 2004/09/30 23:21:19 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.78 2004/10/26 16:05:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -822,11 +822,12 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
for (targoffset = FirstOffsetNumber; targoffset <= maxoffset; targoffset++)
{
HeapTupleData targtuple;
Buffer tupbuffer;
ItemPointerSet(&targtuple.t_self, targblock, targoffset);
if (heap_fetch(onerel, SnapshotNow, &targtuple, &tupbuffer,
false, NULL))
/* We use heap_release_fetch to avoid useless bufmgr traffic */
if (heap_release_fetch(onerel, SnapshotNow,
&targtuple, &targbuffer,
true, NULL))
{
/*
* The first targrows live rows are simply copied into the
@ -869,9 +870,6 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
rowstoskip -= 1;
}
/* must release the extra pin acquired by heap_fetch */
ReleaseBuffer(tupbuffer);
liverows += 1;
}
else
@ -886,7 +884,7 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
}
}
/* Now release the initial pin on the page */
/* Now release the pin on the page */
ReleaseBuffer(targbuffer);
}