From 3d6a98457d8e21d85bed86cfd3e1d1df1b260721 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 5 Apr 2023 08:19:39 -0700 Subject: Don't initialize page in {vm,fsm}_extend(), not needed The read path needs to be able to initialize pages anyway, as relation extensions are not durable. By avoiding initializing pages, we can, in a future patch, extend the relation by multiple blocks at once. Using smgrextend() for {vm,fsm}_extend() is not a good idea in general, as at least one page of the VM/FSM will be read immediately after, always causing a cache miss, requiring us to read content we just wrote. Discussion: https://postgr.es/m/20230301223515.pucbj7nb54n4i4nv@awork3.anarazel.de --- src/backend/storage/freespace/freespace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/backend/storage/freespace/freespace.c') diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c index 3e9693b293b..90c529958e7 100644 --- a/src/backend/storage/freespace/freespace.c +++ b/src/backend/storage/freespace/freespace.c @@ -608,10 +608,9 @@ static void fsm_extend(Relation rel, BlockNumber fsm_nblocks) { BlockNumber fsm_nblocks_now; - PGAlignedBlock pg; + PGAlignedBlock pg = {0}; SMgrRelation reln; - PageInit((Page) pg.data, BLCKSZ, 0); /* * We use the relation extension lock to lock out other backends trying to @@ -649,8 +648,6 @@ fsm_extend(Relation rel, BlockNumber fsm_nblocks) /* Extend as needed. */ while (fsm_nblocks_now < fsm_nblocks) { - PageSetChecksumInplace((Page) pg.data, fsm_nblocks_now); - smgrextend(reln, FSM_FORKNUM, fsm_nblocks_now, pg.data, false); fsm_nblocks_now++; -- cgit v1.2.3