From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: pg_stat_database.xact_commit + pg_stat_database.xact_rollback as a reliable metric for xid consumption ?
Date: Mon, 1 Jun 2020 21:16:43 +0300
Message-ID: <2dde66f6-3842-f3a6-ab1a-b01590789ea8@matrix.gatewaynet.com> (raw)
In-Reply-To: <3B1EF77A-B9DC-4F0A-AD1E-30876F65E2D5@crazybean.net>
References: <51fa222b-374e-39da-eb8c-66d667426bae@matrix.gatewaynet.com>
<CAOBaU_Zc5o=pKopyh=U02xw_FPN_ZWBhqe=-hSTPC-n7JF=X2g@mail.gmail.com>
<36dd7ae2-7c6f-86af-430b-dd9a0f7774b3@matrix.gatewaynet.com>
<CAOBaU_b3BG2jicgv7Woyo8vT1V3dnw4xPvMR=AuZ6hMWYuPjKQ@mail.gmail.com>
<3B1EF77A-B9DC-4F0A-AD1E-30876F65E2D5@crazybean.net>
On 1/6/20 6:58 μ.μ., Rui DeSousa wrote:
>
>> On Jun 1, 2020, at 7:03 AM, Julien Rouhaud <rjuju123@gmail.com> wrote:
>>
>> On Mon, Jun 1, 2020 at 12:48 PM Achilleas Mantzios
>> <achill@matrix.gatewaynet.com> wrote:
>>> On 1/6/20 1:36 μ.μ., Julien Rouhaud wrote:
>>>> On Mon, Jun 1, 2020 at 12:02 PM Achilleas Mantzios
>>>> <achill@matrix.gatewaynet.com> wrote:
>>>> Because read only transaction usually don't consume an xid. So yes
>>>> pg_stat_database gives a more reasonable approximation of the real
>>>> number of transactions happening on the server.
>>> Thank you, so what would be the official way to monitor txid consumption (from a MVCC / Freezing admin POV)?
>> I'm not sure what you're really looking for. If it's the txid
>> consumption rate, you can use txid_current() at regular interval to
>> compute it (note that this function will consume a txid). For object
>> freeeze, you can use age(datfrozenxid) from pg_database, or
>> age(relfrozenxid) from pg_class.
>>
>>
>
> I also record the stats tables every minute by either inserting into a table hist_ table or exporting the data out to be inserted into another table. When exporting the pg_stat_database table I added the following to record the information without the need to call txid_current():
>
> coalesce(txid_current_if_assigned(), txid_snapshot_xmax(txid_current_snapshot())) as xact_txid, …
if this is in the same system, and this _hist table only gets inserts,
selects/delets, why not just use xmin ? Also since you are inserting how
can you have null txid_current_if_assigned()?
>
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: achill@matrix.gatewaynet.com
Subject: Re: pg_stat_database.xact_commit + pg_stat_database.xact_rollback as a reliable metric for xid consumption ?
In-Reply-To: <2dde66f6-3842-f3a6-ab1a-b01590789ea8@matrix.gatewaynet.com>
References: <51fa222b-374e-39da-eb8c-66d667426bae@matrix.gatewaynet.com> <CAOBaU_Zc5o=pKopyh=U02xw_FPN_ZWBhqe=-hSTPC-n7JF=X2g@mail.gmail.com> <36dd7ae2-7c6f-86af-430b-dd9a0f7774b3@matrix.gatewaynet.com> <CAOBaU_b3BG2jicgv7Woyo8vT1V3dnw4xPvMR=AuZ6hMWYuPjKQ@mail.gmail.com> <3B1EF77A-B9DC-4F0A-AD1E-30876F65E2D5@crazybean.net> <2dde66f6-3842-f3a6-ab1a-b01590789ea8@matrix.gatewaynet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox