pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Teja Jakkidi <teja.jakkidi05@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: N_live_tup value is less than actual row count in a table
Date: Fri, 10 Jun 2022 16:46:58 -0400
Message-ID: <2730997.1654894018@sss.pgh.pa.us> (raw)
In-Reply-To: <D93AF3EA-7668-4FFD-87F4-211982B76C17@gmail.com>
References: <D93AF3EA-7668-4FFD-87F4-211982B76C17@gmail.com>

Teja Jakkidi <teja.jakkidi05@gmail.com> writes:
> I have a test table with 100000 rows and I deleted 20000 rows. So the current rows are 80000 and dead tuples should be 20000. After autovacuum completed, the dead tuples were gone.
> When querying the pg_stat_all_tables, it returned n_live_tup value as 63945. Why is it less than actual row count 80000?

The pg_stats counters are only approximate.  In the first place, they're
updated using a simplistic model that can't 100% account for the effects
of concurrent transactions, and in the second place, it's possible for
the stats mechanism to drop update messages altogether under load.
With so few details it's impossible to speculate about just why your
counter was so far off ... but no, you should not expect exactness.

			regards, tom lane





view thread (2+ messages)

Message-ID: <2730997.1654894018@sss.pgh.pa.us>
Permalink:  ../2730997.1654894018@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2730997.1654894018@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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, teja.jakkidi05@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: N_live_tup value is less than actual row count in a table
  In-Reply-To: <2730997.1654894018@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