Re: n_ins_since_vacuum stats for aborted transactions

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Euler Taveira <euler(at)eulerto(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: n_ins_since_vacuum stats for aborted transactions
Date: 2025-04-10 01:48:24
Message-ID: CAApHDvpgV3a-R2EGmPOh0L-x3pHbZpM3y4dySWfy+UqUazwDQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 10 Apr 2025 at 10:54, Sami Imseih <samimseih(at)gmail(dot)com> wrote:
> Fair enough, and I think I got my answers from this thread. This
> design decision was not
> discussed in the thread for b07642dbcd8.

This discussion is mostly settled down now, but...

I also went through that thread to see if it was mentioned and saw
nothing about it.

One possible bad behaviour that this could cause is if
autovacuum_vacuum_insert_scale_factor was set lower than
autovacuum_vacuum_scale_factor is that we could end up performing a
vacuum for inserts when all we've got is dead tuples from aborted
inserts. That does not seem terrible. It's just an extra autovacuum
that could happen in a not very common case. We could fix it but it
would require adding a new field to PgStat_TableCounts to track this
as you can't selectively only update
PgStat_TableCounts.tuples_inserted on commit as the n_tup_ins would
then be wrong.

If the above is the only misbehaviour this is causing, then I'm
doubting that it's worth expanding PgStat_TableCounts by 8 bytes to
have this work better.

> So, I think public documentation updates to clarify that
> n_tup_upd|del|ins, and n_ins_since_vacuum include
> aborted rows is a good enhancement.

A code comment might help settle future debates. If you'd arrived from
a user perspective and were confused about this, then maybe that would
warrant something going into the docs. On the other hand, if you have
a suggestion, please put it into patch form.

I've attached a small patch which adds a code comment about this,
which might save a future discussion.

David

Attachment Content-Type Size
comments_about_using_tuples_inserted_for_ins_since_vacuum.patch application/octet-stream 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-04-10 02:25:38 Re: sync_standbys_defined read/write race on startup
Previous Message Euler Taveira 2025-04-09 23:54:21 Re: Large expressions in indexes can't be stored (non-TOASTable)