mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Cache smgrnblocks() results in recovery.
Avoid repeatedly calling lseek(SEEK_END) during recovery by caching the size of each fork. For now, we can't use the same technique in other processes, because we lack a shared invalidation mechanism. Do this by generalizing the pre-existing caching used by FSM and VM to support all forks. Discussion: https://postgr.es/m/CAEepm%3D3SSw-Ty1DFcK%3D1rU-K6GSzYzfdD4d%2BZwapdN7dTa6%3DnQ%40mail.gmail.com
This commit is contained in:
@@ -290,8 +290,8 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
|
||||
* Make sure smgr_targblock etc aren't pointing somewhere past new end
|
||||
*/
|
||||
rel->rd_smgr->smgr_targblock = InvalidBlockNumber;
|
||||
rel->rd_smgr->smgr_fsm_nblocks = InvalidBlockNumber;
|
||||
rel->rd_smgr->smgr_vm_nblocks = InvalidBlockNumber;
|
||||
for (int i = 0; i <= MAX_FORKNUM; ++i)
|
||||
rel->rd_smgr->smgr_cached_nblocks[i] = InvalidBlockNumber;
|
||||
|
||||
/* Prepare for truncation of MAIN fork of the relation */
|
||||
forks[nforks] = MAIN_FORKNUM;
|
||||
|
||||
Reference in New Issue
Block a user