public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: senor <[email protected]>
To: [email protected] <[email protected]>
Subject: Re: txid_current vs xact_commit stats
Date: Wed, 09 Oct 2024 08:39:35 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <SJ0P221MB06894F3D6D38DE5C61E82B30F77F2@SJ0P221MB0689.NAMP221.PROD.OUTLOOK.COM>
References: <SJ0P221MB06894F3D6D38DE5C61E82B30F77F2@SJ0P221MB0689.NAMP221.PROD.OUTLOOK.COM>

On Wed, 2024-10-09 at 04:22 +0000, senor wrote:
> I was under the impression that all transactions must end with a commit or a
> rollback but watching stats doesn't support this. Web searches tend to return
> info on what a transaction is or the ratio of commits to rollbacks. I found
> nothing contradicting what I think I know.

The rollback can be implicit, for example when you terminate the connection or
crash the server...

Also, PostgreSQL has autocommit, so every data modifying statement that's not
in an explicit transaction will implicitly commit at the end of the statement.

> I've sampled pg_stat_database.xact_commit, pg_stat_database.xact_rollback and
> txid_current() at intervals on a few independent clusters and see that commits
> increase anywhere from 50% to 300% of the rate of transaction increase. Rollback
> remains very near zero for all clusters. Each cluster tends to stay consistently
> within a range (i.e. 120-130% or 50-70%).

Perhaps what I wrote above explains that.

> PG version 11 & 12 on Linux

That's too old.

Yours,
Laurenz Albe






view thread (2+ messages)  latest in thread

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: txid_current vs xact_commit stats
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox