Re: Getting rows in statement-level triggers - Mailing list pgsql-general

From Tom Lane
Subject Re: Getting rows in statement-level triggers
Date
Msg-id 13152.1223077504@sss.pgh.pa.us
Whole thread Raw
In response to Re: Getting rows in statement-level triggers  (Artacus <artacus@comcast.net>)
List pgsql-general
Artacus <artacus@comcast.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

pgsql-general by date:

Previous
From: Joshua Drake
Date:
Subject: Re: failed to install posgrest
Next
From: Erik Jones
Date:
Subject: Re: ]OT] Parsing postgresql.conf archive_command