diff options
author | Thomas Munro <tmunro@postgresql.org> | 2020-07-31 14:15:18 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2020-07-31 14:29:52 +1200 |
commit | c5315f4f44843c20ada876fdb0d0828795dfbdf5 (patch) | |
tree | b94c24609a31ae7243b217ae7d5358c8cff8fe20 /src/include/storage/smgr.h | |
parent | e3931d01f3afef14703827eda1dad0a3fb3b5d07 (diff) | |
download | postgresql-c5315f4f44843c20ada876fdb0d0828795dfbdf5.tar.gz postgresql-c5315f4f44843c20ada876fdb0d0828795dfbdf5.zip |
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
Diffstat (limited to 'src/include/storage/smgr.h')
-rw-r--r-- | src/include/storage/smgr.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index 65666595931..f28a8424013 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -45,15 +45,13 @@ typedef struct SMgrRelationData struct SMgrRelationData **smgr_owner; /* - * These next three fields are not actually used or manipulated by smgr, - * except that they are reset to InvalidBlockNumber upon a cache flush - * event (in particular, upon truncation of the relation). Higher levels - * store cached state here so that it will be reset when truncation - * happens. In all three cases, InvalidBlockNumber means "unknown". + * The following fields are reset to InvalidBlockNumber upon a cache flush + * event, and hold the last known size for each fork. This information is + * currently only reliable during recovery, since there is no cache + * invalidation for fork extension. */ BlockNumber smgr_targblock; /* current insertion target block */ - BlockNumber smgr_fsm_nblocks; /* last known size of fsm fork */ - BlockNumber smgr_vm_nblocks; /* last known size of vm fork */ + BlockNumber smgr_cached_nblocks[MAX_FORKNUM + 1]; /* last known size */ /* additional public fields may someday exist here */ |