mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/storage/large_object.h,v 1.29 2004/08/29 04:13:10 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/storage/large_object.h,v 1.30 2004/09/16 16:58:42 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,7 +20,7 @@
|
||||
* Data about a currently-open large object.
|
||||
*
|
||||
* id is the logical OID of the large object
|
||||
* xid is the transaction Id that opened the LO (or currently owns it)
|
||||
* subid is the subtransaction that opened the LO (or currently owns it)
|
||||
* offset is the current seek offset within the LO
|
||||
* flags contains some flag bits
|
||||
*
|
||||
@@ -32,7 +32,7 @@
|
||||
typedef struct LargeObjectDesc
|
||||
{
|
||||
Oid id; /* LO's identifier */
|
||||
TransactionId xid; /* owning XID */
|
||||
SubTransactionId subid; /* owning subtransaction ID */
|
||||
uint32 offset; /* current seek pointer */
|
||||
int flags; /* locking info, etc */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user