aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/hio.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2023-04-06 14:18:24 -0700
committerAndres Freund <andres@anarazel.de>2023-04-06 16:17:16 -0700
commit5279e9db8e8da3c310c0068da2de98df5a714b2e (patch)
treee38b8127380623775b00564c38f65029543f5956 /src/backend/access/heap/hio.c
parent7d71d3dd080b9b147402db3365fe498f74704231 (diff)
downloadpostgresql-5279e9db8e8da3c310c0068da2de98df5a714b2e.tar.gz
postgresql-5279e9db8e8da3c310c0068da2de98df5a714b2e.zip
heapam: Pass number of required pages to RelationGetBufferForTuple()
A future commit will use this information to determine how aggressively to extend the relation by. In heap_multi_insert() we know accurately how many pages we need once we need to extend the relation, providing an accurate lower bound for how much to extend. Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/20221029025420.eplyow6k7tgu6he3@awork3.anarazel.de
Diffstat (limited to 'src/backend/access/heap/hio.c')
-rw-r--r--src/backend/access/heap/hio.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c
index a0713c178ac..f24e3d96eb9 100644
--- a/src/backend/access/heap/hio.c
+++ b/src/backend/access/heap/hio.c
@@ -301,6 +301,11 @@ RelationAddExtraBlocks(Relation relation, BulkInsertState bistate)
* Returns pinned and exclusive-locked buffer of a page in given relation
* with free space >= given len.
*
+ * If num_pages is > 1, we will try to extend the relation by at least that
+ * many pages when we decide to extend the relation. This is more efficient
+ * for callers that know they will need multiple pages
+ * (e.g. heap_multi_insert()).
+ *
* If otherBuffer is not InvalidBuffer, then it references a previously
* pinned buffer of another page in the same relation; on return, this
* buffer will also be exclusive-locked. (This case is used by heap_update;
@@ -359,7 +364,8 @@ Buffer
RelationGetBufferForTuple(Relation relation, Size len,
Buffer otherBuffer, int options,
BulkInsertState bistate,
- Buffer *vmbuffer, Buffer *vmbuffer_other)
+ Buffer *vmbuffer, Buffer *vmbuffer_other,
+ int num_pages)
{
bool use_fsm = !(options & HEAP_INSERT_SKIP_FSM);
Buffer buffer = InvalidBuffer;