aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/hio.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-06 02:36:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-06 02:36:35 +0000
commit5df307c7782518c4a3c19ffd05c7cb591b97e23c (patch)
tree0ff988dc5b7b115e9f6bbf29852dd4bad7fcaeea /src/backend/access/heap/hio.c
parent35cd432b185938c33967c9fa48223ce33e1c66bd (diff)
downloadpostgresql-5df307c7782518c4a3c19ffd05c7cb591b97e23c.tar.gz
postgresql-5df307c7782518c4a3c19ffd05c7cb591b97e23c.zip
Restructure local-buffer handling per recent pghackers discussion.
The local buffer manager is no longer used for newly-created relations (unless they are TEMP); a new non-TEMP relation goes through the shared bufmgr and thus will participate normally in checkpoints. But TEMP relations use the local buffer manager throughout their lifespan. Also, operations in TEMP relations are not logged in WAL, thus improving performance. Since it's no longer necessary to fsync relations as they move out of the local buffers into shared buffers, quite a lot of smgr.c/md.c/fd.c code is no longer needed and has been removed: there's no concept of a dirty relation anymore in md.c/fd.c, and we never fsync anything but WAL. Still TODO: improve local buffer management algorithms so that it would be reasonable to increase NLocBuffer.
Diffstat (limited to 'src/backend/access/heap/hio.c')
-rw-r--r--src/backend/access/heap/hio.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c
index 602ad748d9b..67eb4ad7e24 100644
--- a/src/backend/access/heap/hio.c
+++ b/src/backend/access/heap/hio.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Id: hio.c,v 1.45 2002/06/20 20:29:25 momjian Exp $
+ * $Id: hio.c,v 1.46 2002/08/06 02:36:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,6 +102,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
Size pageFreeSpace;
BlockNumber targetBlock,
otherBlock;
+ bool needLock;
len = MAXALIGN(len); /* be conservative */
@@ -231,9 +232,12 @@ RelationGetBufferForTuple(Relation relation, Size len,
*
* We have to use a lock to ensure no one else is extending the rel at
* the same time, else we will both try to initialize the same new
- * page.
+ * page. We can skip locking for new or temp relations, however,
+ * since no one else could be accessing them.
*/
- if (!relation->rd_myxactonly)
+ needLock = !(relation->rd_isnew || relation->rd_istemp);
+
+ if (needLock)
LockPage(relation, 0, ExclusiveLock);
/*
@@ -249,7 +253,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
* Release the file-extension lock; it's now OK for someone else to
* extend the relation some more.
*/
- if (!relation->rd_myxactonly)
+ if (needLock)
UnlockPage(relation, 0, ExclusiveLock);
/*