diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-16 16:58:44 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-16 16:58:44 +0000 |
commit | 8f9f1986034a2273e09ad10671e10d1adda21d1f (patch) | |
tree | 4c2c8a226db335cf1e653b09026402363d0488e7 /src/backend/access/transam/xlog.c | |
parent | 42c0d1f3cd01ac737b182353934531d1fd382c80 (diff) | |
download | postgresql-8f9f1986034a2273e09ad10671e10d1adda21d1f.tar.gz postgresql-8f9f1986034a2273e09ad10671e10d1adda21d1f.zip |
Restructure subtransaction handling to reduce resource consumption,
as per recent discussions. Invent SubTransactionIds that are managed like
CommandIds (ie, counter is reset at start of each top transaction), and
use these instead of TransactionIds to keep track of subtransaction status
in those modules that need it. This means that a subtransaction does not
need an XID unless it actually inserts/modifies rows in the database.
Accordingly, don't assign it an XID nor take a lock on the XID until it
tries to do that. This saves a lot of overhead for subtransactions that
are only used for error recovery (eg plpgsql exceptions). Also, arrange
to release a subtransaction's XID lock as soon as the subtransaction
exits, in both the commit and abort cases. This avoids holding many
unique locks after a long series of subtransactions. The price is some
additional overhead in XactLockTableWait, but that seems acceptable.
Finally, restructure the state machine in xact.c to have a more orthogonal
set of states for subtransactions.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0e27ba319a1..d46a3e543d8 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.169 2004/09/06 03:04:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.170 2004/09/16 16:58:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -747,7 +747,7 @@ begin:; /* Insert record header */ record->xl_prev = Insert->PrevRecord; - record->xl_xid = GetCurrentTransactionId(); + record->xl_xid = GetCurrentTransactionIdIfAny(); record->xl_len = len; /* doesn't include backup blocks */ record->xl_info = info; record->xl_rmid = rmid; |