mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Adjust btree index build to not use shared buffers, thereby avoiding the
locking conflict against concurrent CHECKPOINT that was discussed a few weeks ago. Also, if not using WAL archiving (which is always true ATM but won't be if PITR makes it into this release), there's no need to WAL-log the index build process; it's sufficient to force-fsync the completed index before commit. This seems to gain about a factor of 2 in my tests, which is consistent with writing half as much data. I did not try it with WAL on a separate drive though --- probably the gain would be a lot less in that scenario.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.106 2004/05/31 20:31:33 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.107 2004/06/02 17:28:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -661,6 +661,40 @@ mdtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp)
|
||||
return nblocks;
|
||||
}
|
||||
|
||||
/*
|
||||
* mdimmedsync() -- Immediately sync a relation to stable storage.
|
||||
*/
|
||||
bool
|
||||
mdimmedsync(SMgrRelation reln)
|
||||
{
|
||||
MdfdVec *v;
|
||||
BlockNumber curnblk;
|
||||
|
||||
/*
|
||||
* NOTE: mdnblocks makes sure we have opened all existing segments, so
|
||||
* that fsync loop will get them all!
|
||||
*/
|
||||
curnblk = mdnblocks(reln);
|
||||
if (curnblk == InvalidBlockNumber)
|
||||
return false; /* mdnblocks failed */
|
||||
|
||||
v = mdopen(reln, false);
|
||||
|
||||
#ifndef LET_OS_MANAGE_FILESIZE
|
||||
while (v != NULL)
|
||||
{
|
||||
if (FileSync(v->mdfd_vfd) < 0)
|
||||
return false;
|
||||
v = v->mdfd_chain;
|
||||
}
|
||||
#else
|
||||
if (FileSync(v->mdfd_vfd) < 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* mdsync() -- Sync previous writes to stable storage.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user