Adjust btree index build to not use shared buffers, thereby avoiding the
Tom Lane <tgl@sss.pgh.pa.us>
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.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/nbtree/nbtpage.c | modified | +32 −89 |
| src/backend/access/nbtree/nbtree.c | modified | +6 −5 |
| src/backend/access/nbtree/nbtsort.c | modified | +182 −78 |
| src/backend/access/nbtree/nbtxlog.c | modified | +10 −32 |
| src/backend/storage/smgr/md.c | modified | +35 −1 |
| src/backend/storage/smgr/smgr.c | modified | +32 −2 |
| src/include/access/nbtree.h | modified | +4 −6 |
| src/include/storage/smgr.h | modified | +3 −1 |