public inbox for [email protected]  
help / color / mirror / Atom feed
Re: txid_current vs xact_commit stats
2+ messages / 2 participants
[nested] [flat]

* Re: txid_current vs xact_commit stats
@ 2024-10-09 06:39 Laurenz Albe <[email protected]>
  2024-10-09 18:40 ` Re: txid_current vs xact_commit stats Eddie Mishler <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Laurenz Albe @ 2024-10-09 06:39 UTC (permalink / raw)
  To: senor <[email protected]>; [email protected] <[email protected]>

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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: txid_current vs xact_commit stats
  2024-10-09 06:39 Re: txid_current vs xact_commit stats Laurenz Albe <[email protected]>
@ 2024-10-09 18:40 ` Eddie Mishler <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Eddie Mishler @ 2024-10-09 18:40 UTC (permalink / raw)
  To: [email protected] <[email protected]>


On 10/8/2024 23:39, Laurenz Albe wrote:
> 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.
This part I'm aware of but I assume whether implicit or explicit it 
would show up in the stats I'm monitoring.
>> 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.
How is it that I'm seeing more commits than transactions? I thought I 
should see something as simple as commits + rollbacks = transactions.  
In some cases I'm seeing 3 times as many commits. I'm not aware of 
multiple commits possible per transaction or commits without a 
transaction.  There doesn't seem to be a problem other than my 
understanding.
>> PG version 11 & 12 on Linux
> That's too old.
100% agree.
> Yours,
> Laurenz Albe

Thank you Laurenz for the response. Your replies to my previous posts 
helped to identify there is an ongoing issue with the stats collection 
in some clusters. I'm looking forward to an upgrade to PG v16 to manage 
that.  This current question came up while looking into that but I don't 
think it's involved.

Thanks,

Senor







^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-10-09 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 06:39 Re: txid_current vs xact_commit stats Laurenz Albe <[email protected]>
2024-10-09 18:40 ` Eddie Mishler <[email protected]>

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