Re: Why does txid_current() assign new transaction-id? - Mailing list pgsql-hackers

From Christoph Berg
Subject Re: Why does txid_current() assign new transaction-id?
Date
Msg-id 20150526172714.GF15206@msg.df7cb.de
Whole thread Raw
In response to Re: Why does txid_current() assign new transaction-id?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Why does txid_current() assign new transaction-id?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Re: Tom Lane 2015-05-26 <14207.1432650862@sss.pgh.pa.us>
> Naoya Anzai <nao-anzai@xc.jp.nec.com> writes:
> > I have a question about txid_current().
> > it is "Why does txid_current() assign new transaction-id?".
> 
> Consider
> 
>     begin;
>     select txid_current();
>     insert into my_table ...;
>     commit;
> 
> If we changed the code as you propose, the result of the SELECT would
> no longer have anything to do with the XID used for the insertion.

Still, exposing GetStableLatestTransactionId() on the SQL level would
make sense for monitoring transaction throughput. Currently if you do
that with txid_current(), you'll generate an (low, but measurable)
transaction load of 1/monitoring interval.

Christoph
-- 
cb@df7cb.de | http://www.df7cb.de/



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: fsync-pgdata-on-recovery tries to write to more files than previously
Next
From: Tom Lane
Date:
Subject: Re: Why does txid_current() assign new transaction-id?