Re: Getting rows in statement-level triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Artacus <artacus(at)comcast(dot)net>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting rows in statement-level triggers
Date: 2008-10-03 23:45:04
Message-ID: 13152.1223077504@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Artacus <artacus(at)comcast(dot)net> writes:
>> This will not work, or at least it will stop working after your
>> installation passes 4 billion transactions.

> * So what exactly happens at the 4 billion mark?

txid keeps going (that's why it's a bigint). xid will wrap around.

> * Why can't I cast an xid to int or bigint?

No very strong reason except that no such code is provided...
but you do have to think hard about the fact that xid comparison
is circular and does not work at all like integer comparison.

> * The table in question is the largest in the db. How performative
> is it to query based on xmin? Is xmin indexed? Can it be?

Not very, no, and no.

If you were really desperate you could make an indexed bigint column
that was filled with current_txid by an insert/update trigger, and
then search on that.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2008-10-03 23:52:41 Re: ]OT] Parsing postgresql.conf archive_command
Previous Message Joshua Drake 2008-10-03 23:36:31 Re: failed to install posgrest