summaryrefslogtreecommitdiff
path: root/src/include/utils/rel.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-09-16 16:58:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-09-16 16:58:44 +0000
commit8f9f1986034a2273e09ad10671e10d1adda21d1f (patch)
tree4c2c8a226db335cf1e653b09026402363d0488e7 /src/include/utils/rel.h
parent42c0d1f3cd01ac737b182353934531d1fd382c80 (diff)
downloadpostgresql-8f9f1986034a2273e09ad10671e10d1adda21d1f.tar.gz
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/utils/rel.h')
-rw-r--r--src/include/utils/rel.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 2875efac6f..adcd82a9c9 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -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/include/utils/rel.h,v 1.79 2004/08/29 05:06:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.80 2004/09/16 16:58:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -115,12 +115,12 @@ typedef struct RelationData
bool rd_isvalid; /* relcache entry is valid */
char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1
* = valid, 2 = temporarily forced */
- TransactionId rd_createxact; /* rel was created in current xact */
+ SubTransactionId rd_createSubid; /* rel was created in current xact */
/*
- * rd_createxact is the XID of the highest subtransaction the rel has
+ * rd_createSubid is the ID of the highest subtransaction the rel has
* survived into; or zero if the rel was not created in the current
- * transaction. This should be relied on only for optimization
+ * top transaction. This should be relied on only for optimization
* purposes; it is possible for new-ness to be "forgotten" (eg, after
* CLUSTER).
*/
@@ -241,7 +241,8 @@ typedef Relation *RelationPtr;
* Beware of multiple eval of argument
*/
#define RELATION_IS_LOCAL(relation) \
- ((relation)->rd_istemp || TransactionIdIsValid((relation)->rd_createxact))
+ ((relation)->rd_istemp || \
+ (relation)->rd_createSubid != InvalidSubTransactionId)
/* routines in utils/cache/relcache.c */
extern void RelationIncrementReferenceCount(Relation rel);