Re: txid_current vs xact_commit stats

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: senor <frio_cervesa(at)hotmail(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: txid_current vs xact_commit stats
Date: 2024-10-09 06:39:35
Message-ID: fedd43e27a744a8d15dc574d1ba53d4c46b76cf8.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Torsten Förtsch 2024-10-09 09:52:26 Re: Disk is filling up with large files. How can I clean?
Previous Message senor 2024-10-09 04:22:41 txid_current vs xact_commit stats