diff options
| author | Tom Lane | 2004-09-16 16:58:44 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-09-16 16:58:44 +0000 |
| commit | 8f9f1986034a2273e09ad10671e10d1adda21d1f (patch) | |
| tree | 4c2c8a226db335cf1e653b09026402363d0488e7 /src/include/c.h | |
| parent | 42c0d1f3cd01ac737b182353934531d1fd382c80 (diff) | |
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/include/c.h')
| -rw-r--r-- | src/include/c.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/include/c.h b/src/include/c.h index 4d295510dcf..cfce57c070a 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.171 2004/09/10 15:51:47 momjian Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.172 2004/09/16 16:58:38 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -351,7 +351,7 @@ typedef float float4; typedef double float8; /* - * Oid, RegProcedure, TransactionId, CommandId, AclId + * Oid, RegProcedure, TransactionId, SubTransactionId, CommandId, AclId */ /* typedef Oid is in postgres_ext.h */ @@ -365,6 +365,11 @@ typedef regproc RegProcedure; typedef uint32 TransactionId; +typedef uint32 SubTransactionId; + +#define InvalidSubTransactionId ((SubTransactionId) 0) +#define TopSubTransactionId ((SubTransactionId) 1) + typedef uint32 CommandId; #define FirstCommandId ((CommandId) 0) |
