txid_current vs xact_commit stats

From: senor <frio_cervesa(at)hotmail(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: txid_current vs xact_commit stats
Date: 2024-10-09 04:22:41
Message-ID: SJ0P221MB06894F3D6D38DE5C61E82B30F77F2@SJ0P221MB0689.NAMP221.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

HI All;

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.

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%).

I've seen strange issues with the stats collector missing updates and causing problems with autovacuum but that wouldn't explain more commits than transactions. All clusters receive many inserts (~10-100) in single transactions but AFAIK this still counts as a single commit. Many other tables are created while processing the inserted data and much of that is done within transaction blocks. I'm not aware of anything very sophisticated in the application handling this but I could be wrong.

I'm probably missing something fundamental. I know what I know but I'm not a DBA.
PG version 11 & 12 on Linux

Any hints and references appreciated.
Thanks,
Senor

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2024-10-09 06:39:35 Re: txid_current vs xact_commit stats
Previous Message Paul Brindusa 2024-10-08 17:00:38 Re: libpq5 error