pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: incoherent dead tuples between pg_stat_user_tables and pgstattuple?
Date: Fri, 27 Sep 2019 09:52:22 -0400
Message-ID: <20077.1569592342@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKoxK+4guWzkhxgzrr5G5WfB+sHwbKc8DJdVaOsO9mVgU92f2Q@mail.gmail.com>
References: <CAKoxK+4guWzkhxgzrr5G5WfB+sHwbKc8DJdVaOsO9mVgU92f2Q@mail.gmail.com>

Luca Ferrari <fluca1978@gmail.com> writes:
> running 11.5 I've some misconception about pgstatuple: it seems it
> lags behind normal statistics.

n_live_tup/n_dead_tup should not be thought to be better than
approximations.  Most operations adjust them only incrementally,
and messages to the stats collector can get dropped entirely
under heavy load, causing deltas to go missing.  There are
also race conditions involved in some update scenarios.

> Even after running an ANALYZE, pgstattuple provides the same results.
> After a VACUUM FULL ANALYZE the world is as I would expect it to be:

VACUUM FULL is one of very few operations that reset those counters
to guaranteed-correct values (and I'm not sure the guarantee is
ironclad even in that case).

It's very hard to improve on this without giving up the desirable
ability to have concurrent table updates.  If you really want an
accurate row count, COUNT(*) or pgstattuples will give you a more
reliable estimate ... at much higher cost, of course.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <20077.1569592342@sss.pgh.pa.us>
Permalink:  ../20077.1569592342@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20077.1569592342@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, fluca1978@gmail.com
  Subject: Re: incoherent dead tuples between pg_stat_user_tables and pgstattuple?
  In-Reply-To: <20077.1569592342@sss.pgh.pa.us>
  References: <CAKoxK+4guWzkhxgzrr5G5WfB+sHwbKc8DJdVaOsO9mVgU92f2Q@mail.gmail.com> <20077.1569592342@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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