On Sat, Jul 03, 2004 at 11:03:33AM -0400, Tom Lane wrote: > TransactionIdIsInProgress needs work/review; comments are off for one > thing, and it seems *way* too inefficient. Note it should be possible to > skip subtrans search for sufficiently old xacts (hm ... couldn't we skip > sinval search too...)
I am looking at this now ... the first thing I did was stamp at the start of the function if (TransactionIdPrecedes(xid, RecentGlobalXmin)) return false; So we don't need to check pg_subtrans (nor the PGPROC array) for any transaction that is too old. Now, I'm looking at adding the array of cached Xids and I think that maybe this is not the cure to all the performance problems introduced. With the cached Xid array we can return quickly for a transaction that is part of any of the current subtransaction trees, but there's no way to know about "negative hits"! So any time a Xid that's not part of any transaction tree is sought, we'd have to revert to pg_subtrans. This includes an aborted subtransaction of a current transaction tree. So how about adding two arrays to PGPROC: the cached Xid array (for subcommitted subxacts) and another which would hold aborted Xids? We would store Xids of aborted subxacts of the current transaction. (Maybe we could store Xids of previous transactions of this backend too?) Instead of the second array, we could have a global TransactionId array which would hold past transactions and aborted subtransactions for all backends. At AbortTransaction() and AbortSubTransaction() we would save the Xid there, using a round-robin scheme. What do you think? -- Alvaro Herrera (<alvherre[a]dcc.uchile.cl>) "No single strategy is always right (Unless the boss says so)" (Larry Wall) ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster