On Monday, September 28, 2020 5:08 PM, Tsunakawa-san wrote: > From: Jamison, Kirk/ジャミソン カーク <k.jami...@fujitsu.com> > > Is my understanding above correct? > > No. I simply meant DropRelFileNodeBuffers() calls the following function, > and avoids the optimization if it returns InvalidBlockNumber. > > > BlockNumber > smgrcachednblocks(SMgrRelation reln, ForkNumber forknum) { > return reln->smgr_cached_nblocks[forknum]; > }
Thank you for clarifying. So in the new function, it goes something like: if (InRecovery) { if (reln->smgr_cached_nblocks[forknum] != InvalidBlockNumber) return reln->smgr_cached_nblocks[forknum]; else return InvalidBlockNumber; } I've revised the patch and added the new function accordingly in the attached file. I also did not remove the duplicate code from smgrnblocks because Amit-san mentioned that when the caching for non-recovery cases is implemented, we can use it for non-recovery cases as well. Although I am not sure if the way it's written in DropRelFileNodeBuffers is okay. BlockNumberIsValid(nTotalBlocks) nTotalBlocks = smgrcachednblocks(smgr_reln, forkNum[j]); nBlocksToInvalidate = nTotalBlocks - firstDelBlock[j]; if (BlockNumberIsValid(nTotalBlocks) && nBlocksToInvalidate < BUF_DROP_FULLSCAN_THRESHOLD) { //enter optimization loop } else { //full scan for each fork } Regards, Kirk Jamison
v17-Optimize-DropRelFileNodeBuffers-during-recovery.patch
Description: v17-Optimize-DropRelFileNodeBuffers-during-recovery.patch
v1-Prevent-invalidating-blocks-in-smgrextend-during-recovery.patch
Description: v1-Prevent-invalidating-blocks-in-smgrextend-during-recovery.patch