Re: Wrong stat on pg_stat_user_tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas SIMON <tsimon(at)neteven(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Wrong stat on pg_stat_user_tables
Date: 2016-09-27 13:57:48
Message-ID: 31468.1474984668@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thomas SIMON <tsimon(at)neteven(dot)com> writes:
> I have strange behavior with a stat of pg_stat_user_tables (explained
> below), where number of live tuples is not the real number at all.
> ...
> I've comparated my 10 biggest tables, only this table gave me wrong results.

The pgstats stats are only approximate, but ideally they'd converge
towards reality over time when they're wrong. Seems like maybe this one
table has a usage pattern that's odd enough to throw things off. Maybe
you have unusual autovacuum/autoanalyze parameters for it, for example?
Is there anything strange about the way you insert/update/delete in it?

A simpler explanation might be that this table has inheritance children
--- the pgstats count would consider only the table itself, but
"select count(1) from items" would scan the child tables too.

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Glyn Astill 2016-09-27 14:01:53 Re: Wrong stat on pg_stat_user_tables
Previous Message Scott Whitney 2016-09-27 13:21:00 Re: /var/run/postgresql/.s.PGSQL.5432 should be 5433