mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
The new facility makes it easier to optimize bulk loading, as the logic for buffering, WAL-logging, and syncing the relation only needs to be implemented once. It's also less error-prone: We have had a number of bugs in how a relation is fsync'd - or not - at the end of a bulk loading operation. By centralizing that logic to one place, we only need to write it correctly once. The new facility is faster for small relations: Instead of of calling smgrimmedsync(), we register the fsync to happen at next checkpoint, which avoids the fsync latency. That can make a big difference if you are e.g. restoring a schema-only dump with lots of relations. It is also slightly more efficient with large relations, as the WAL logging is performed multiple pages at a time. That avoids some WAL header overhead. The sorted GiST index build did that already, this moves the buffering to the new facility. The changes to pageinspect GiST test needs an explanation: Before this patch, the sorted GiST index build set the LSN on every page to the special GistBuildLSN value, not the LSN of the WAL record, even though they were WAL-logged. There was no particular need for it, it just happened naturally when we wrote out the pages before WAL-logging them. Now we WAL-log the pages first, like in B-tree build, so the pages are stamped with the record's real LSN. When the build is not WAL-logged, we still use GistBuildLSN. To make the test output predictable, use an unlogged index. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/30e8f366-58b3-b239-c521-422122dd5150%40iki.fi
57 lines
2.3 KiB
C
57 lines
2.3 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* md.h
|
|
* magnetic disk storage manager public interface declarations.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/storage/md.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef MD_H
|
|
#define MD_H
|
|
|
|
#include "storage/block.h"
|
|
#include "storage/relfilelocator.h"
|
|
#include "storage/smgr.h"
|
|
#include "storage/sync.h"
|
|
|
|
/* md storage manager functionality */
|
|
extern void mdinit(void);
|
|
extern void mdopen(SMgrRelation reln);
|
|
extern void mdclose(SMgrRelation reln, ForkNumber forknum);
|
|
extern void mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
|
|
extern bool mdexists(SMgrRelation reln, ForkNumber forknum);
|
|
extern void mdunlink(RelFileLocatorBackend rlocator, ForkNumber forknum, bool isRedo);
|
|
extern void mdextend(SMgrRelation reln, ForkNumber forknum,
|
|
BlockNumber blocknum, const void *buffer, bool skipFsync);
|
|
extern void mdzeroextend(SMgrRelation reln, ForkNumber forknum,
|
|
BlockNumber blocknum, int nblocks, bool skipFsync);
|
|
extern bool mdprefetch(SMgrRelation reln, ForkNumber forknum,
|
|
BlockNumber blocknum, int nblocks);
|
|
extern void mdreadv(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
|
void **buffers, BlockNumber nblocks);
|
|
extern void mdwritev(SMgrRelation reln, ForkNumber forknum,
|
|
BlockNumber blocknum,
|
|
const void **buffers, BlockNumber nblocks, bool skipFsync);
|
|
extern void mdwriteback(SMgrRelation reln, ForkNumber forknum,
|
|
BlockNumber blocknum, BlockNumber nblocks);
|
|
extern BlockNumber mdnblocks(SMgrRelation reln, ForkNumber forknum);
|
|
extern void mdtruncate(SMgrRelation reln, ForkNumber forknum,
|
|
BlockNumber nblocks);
|
|
extern void mdimmedsync(SMgrRelation reln, ForkNumber forknum);
|
|
extern void mdregistersync(SMgrRelation reln, ForkNumber forknum);
|
|
|
|
extern void ForgetDatabaseSyncRequests(Oid dbid);
|
|
extern void DropRelationFiles(RelFileLocator *delrels, int ndelrels, bool isRedo);
|
|
|
|
/* md sync callbacks */
|
|
extern int mdsyncfiletag(const FileTag *ftag, char *path);
|
|
extern int mdunlinkfiletag(const FileTag *ftag, char *path);
|
|
extern bool mdfiletagmatches(const FileTag *ftag, const FileTag *candidate);
|
|
|
|
#endif /* MD_H */
|