Re: n_ins_since_vacuum stats for aborted transactions

Sami Imseih <samimseih@gmail.com>

From: Sami Imseih <samimseih@gmail.com>
To: Euler Taveira <euler@eulerto.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-04-09T18:31:55Z
Lists: pgsql-hackers
> This is *not* an oversight. It is by design. See commit b07642dbcd8d. The
> documentation says

I don't see in the commit message why inserts in an aborted transaction
must count towards n_ins_since_vacuum.

>   Estimated number of rows inserted since this table was last vacuumed
>
> Those rows were actually inserted. They are physically in the data files. And
> that's what matters for the autovacuum algorithm.

Correct,but they are dead tuples that are physically in the files, and
are accounted for through
n_dead_tup and are then cleaned up based on the
autovacuum_vacuum_scale_factor|threshold
calculation.

The purpose of b07642dbcd8d is to trigger autovacuum for append only/mainly
workloads that don't generate dead tuples.

--
Sami Imseih
Amazon Web Services (AWS)



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add code comment explaining ins_since_vacuum and aborted inserts

  2. Trigger autovacuum based on number of INSERTs