Re: Re: [HACKERS] [COMMITTERS] pgsql: Fix TransactionIdIsCurrentTransactionId() to use binary search

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: Re: [HACKERS] [COMMITTERS] pgsql: Fix TransactionIdIsCurrentTransactionId() to use binary search
Date: 2008-04-26 23:20:29
Message-ID: 11001.1209252029@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers pgsql-performance

Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> writes:
> On Saturday 26 April 2008 13:26, Tom Lane wrote:
>> Oh, you failed to state that the dtrace output was post-patch. You need
>> to show *pre* patch dtrace output if you want us to think it relevant.

> Please read up-thread.

Sorry, I'd forgotten your previous post.

I poked around for calls to TransactionIdIsCurrentTransactionId that
are in current code and weren't in 8.1. I found these:

src/backend/commands/analyze.c: 965: if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(targtuple.t_data)))
src/backend/commands/analyze.c: 984: if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(targtuple.t_data)))
src/backend/commands/cluster.c: 803: if (!TransactionIdIsCurrentTransactionId(
src/backend/commands/cluster.c: 816: if (!TransactionIdIsCurrentTransactionId(
src/backend/storage/ipc/procarray.c: 374: if (TransactionIdIsCurrentTransactionId(xid))
src/backend/utils/time/combocid.c: 108: Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tup)));
src/backend/utils/time/combocid.c: 123: Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tup)));
src/backend/utils/time/combocid.c: 156: TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tup)))

The ANALYZE and CLUSTER calls are not likely to be your issue, but the
one in HeapTupleHeaderAdjustCmax could get called a lot, and the one
in TransactionIdIsInProgress definitely will get called a lot.
Neither of those calls existed in 8.2.

So I think that explains why TransactionIdIsCurrentTransactionId has
become more performance-critical in 8.3 than it was before. Will
apply the back-patch.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2008-04-26 23:35:33 pgsql: Back-patch Heikki's fix to make
Previous Message Tom Lane 2008-04-26 22:47:40 pgsql: Code review for recent patch to terminate online backup during

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-04-27 02:01:10 Traveling this week
Previous Message Robert Treat 2008-04-26 18:20:15 Re: Re: [HACKERS] [COMMITTERS] pgsql: Fix TransactionIdIsCurrentTransactionId() to use binary search

Browse pgsql-performance by date

  From Date Subject
Next Message Jonah H. Harris 2008-04-27 01:14:53 Re: Best practice to load a huge table from ORACLE to PG
Previous Message Craig Ringer 2008-04-26 18:51:55 Re: Best practice to load a huge table from ORACLE to PG