Re: Incorrect accounting (n_tup_ins) of non-inserted rows - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Incorrect accounting (n_tup_ins) of non-inserted rows
Date
Msg-id 15621.1458307531@sss.pgh.pa.us
Whole thread Raw
In response to Incorrect accounting (n_tup_ins) of non-inserted rows  (Ilya Matveychikov <matvejchikov@gmail.com>)
Responses Re: Incorrect accounting (n_tup_ins) of non-inserted rows
List pgsql-bugs
Ilya Matveychikov <matvejchikov@gmail.com> writes:
> Seems that accounting of insertions with `n_tup_ins` not correct in
> case of insertion errors cause by constraints checking (duplicate key
> value violates unique constraint):

You already found one of the many code comments indicating that this is
the intended behavior:

> CODE REFERENCE (src/backend/postmaster/pgstat.c)
> /* count attempted actions regardless of commit/abort */

> So, is this behavior normal or probably needs to be fixed?

No, it's not a bug, and it's not going to be fixed.  For many of the
intended applications of those counts (e.g, determining whether
autovacuum/autoanalyze is needed), this is the correct behavior
and ignoring actions of failed transactions would be incorrect.

The live/dead tuple counts do attempt to take transaction success
into account; perhaps looking at those would be more helpful for
your use-case?

            regards, tom lane

pgsql-bugs by date:

Previous
From: Ilya Matveychikov
Date:
Subject: Incorrect accounting (n_tup_ins) of non-inserted rows
Next
From: Tom Lane
Date:
Subject: Re: BUG #13750: Autovacuum slows down with large numbers of tables. More workers makes it slower.