aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorVadim B. Mikheev <vadim4o@yahoo.com>1999-06-29 04:54:49 +0000
committerVadim B. Mikheev <vadim4o@yahoo.com>1999-06-29 04:54:49 +0000
commit49f68a8584b03996cd9e8c080fa665f3e406842e (patch)
treeb74b10f1031af41e0c20da7350a821d4aac1f657 /src/backend/access
parentcffd0f9c89b609801592147440f6f57115367034 (diff)
downloadpostgresql-49f68a8584b03996cd9e8c080fa665f3e406842e.tar.gz
postgresql-49f68a8584b03996cd9e8c080fa665f3e406842e.zip
Avoid disk writes for read-only transactions.
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/transam/xact.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 4689a2f82ea..cd860e0450b 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.41 1999/06/10 14:17:06 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.42 1999/06/29 04:54:46 vadim Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -158,6 +158,8 @@
#include <commands/sequence.h>
#include <libpq/be-fsstubs.h>
+extern bool SharedBufferChanged;
+
static void AbortTransaction(void);
static void AtAbort_Cache(void);
static void AtAbort_Locks(void);
@@ -618,30 +620,36 @@ RecordTransactionCommit()
*/
xid = GetCurrentTransactionId();
- /* ----------------
+ /*
* flush the buffer manager pages. Note: if we have stable
* main memory, dirty shared buffers are not flushed
* plai 8/7/90
- * ----------------
*/
leak = BufferPoolCheckLeak();
- FlushBufferPool(!TransactionFlushEnabled());
- if (leak)
- ResetBufferPool();
- /* ----------------
- * have the transaction access methods record the status
- * of this transaction id in the pg_log / pg_time relations.
- * ----------------
+ /*
+ * If no one shared buffer was changed by this transaction then
+ * we don't flush shared buffers and don't record commit status.
*/
- TransactionIdCommit(xid);
+ if (SharedBufferChanged)
+ {
+ FlushBufferPool(!TransactionFlushEnabled());
+ if (leak)
+ ResetBufferPool();
+
+ /*
+ * have the transaction access methods record the status
+ * of this transaction id in the pg_log relation.
+ */
+ TransactionIdCommit(xid);
+
+ /*
+ * Now write the log info to the disk too.
+ */
+ leak = BufferPoolCheckLeak();
+ FlushBufferPool(!TransactionFlushEnabled());
+ }
- /* ----------------
- * Now write the log/time info to the disk too.
- * ----------------
- */
- leak = BufferPoolCheckLeak();
- FlushBufferPool(!TransactionFlushEnabled());
if (leak)
ResetBufferPool();
}
@@ -731,19 +739,14 @@ RecordTransactionAbort()
*/
xid = GetCurrentTransactionId();
- /* ----------------
- * have the transaction access methods record the status
- * of this transaction id in the pg_log / pg_time relations.
- * ----------------
+ /*
+ * Have the transaction access methods record the status of
+ * this transaction id in the pg_log relation. We skip it
+ * if no one shared buffer was changed by this transaction.
*/
- TransactionIdAbort(xid);
+ if (SharedBufferChanged)
+ TransactionIdAbort(xid);
- /* ----------------
- * flush the buffer manager pages. Note: if we have stable
- * main memory, dirty shared buffers are not flushed
- * plai 8/7/90
- * ----------------
- */
ResetBufferPool();
}
@@ -965,6 +968,7 @@ CommitTransaction()
* ----------------
*/
s->state = TRANS_DEFAULT;
+ SharedBufferChanged = false; /* safest place to do it */
}
@@ -1028,6 +1032,7 @@ AbortTransaction()
* ----------------
*/
s->state = TRANS_DEFAULT;
+ SharedBufferChanged = false; /* safest place to do it */
}
/* --------------------------------