Re: Why does txid_current() assign new transaction-id?

From: Christoph Berg <myon(at)debian(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Naoya Anzai <nao-anzai(at)xc(dot)jp(dot)nec(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Akio Iwaasa <aki-iwaasa(at)vt(dot)jp(dot)nec(dot)com>
Subject: Re: Why does txid_current() assign new transaction-id?
Date: 2015-05-26 17:27:14
Message-ID: 20150526172714.GF15206@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Re: Tom Lane 2015-05-26 <14207(dot)1432650862(at)sss(dot)pgh(dot)pa(dot)us>
> Naoya Anzai <nao-anzai(at)xc(dot)jp(dot)nec(dot)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(at)df7cb(dot)de | http://www.df7cb.de/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-05-26 17:38:25 Re: Why does txid_current() assign new transaction-id?
Previous Message Andres Freund 2015-05-26 17:13:40 Re: fsync-pgdata-on-recovery tries to write to more files than previously