RelationTruncate() invalidates the cached fork sizes as follows. This causes smgrnblocks() return accurate=false,
resultingin not running optimization. Try commenting out for non-recovery case.
/*
* Make sure smgr_targblock etc aren't pointing somewhere past new end
*/
rel->rd_smgr->smgr_targblock = InvalidBlockNumber;
for (int i = 0; i <= MAX_FORKNUM; ++i)
rel->rd_smgr->smgr_cached_nblocks[i] = InvalidBlockNumber;
Regards
Takayuki Tsunakawa