pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sherrylyn Branchaw <sbranchaw@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Does pg_stat_get_live_tuples() matter?
Date: Wed, 10 Apr 2019 00:10:32 -0400
Message-ID: <1935.1554869432@sss.pgh.pa.us> (raw)
In-Reply-To: <CAB_myF4K=VFL=VF41k2=qNgTQ=r0AzojmBin=ejVHT9A-wat3A@mail.gmail.com>
References: <CAB_myF4K=VFL=VF41k2=qNgTQ=r0AzojmBin=ejVHT9A-wat3A@mail.gmail.com>

Sherrylyn Branchaw <sbranchaw@gmail.com> writes:
> If a table has 1.8M rows in reality, yet pg_stat_get_live_tuples() returns
> 1.8K, does it matter to the performance of the database, as long as
> pg_class.reltuples is the right order of magnitude?

Hmmm ... what was in reltuples again?  Looking at the current code,
it looks like vacuum or autovacuum should set reltuples and n_live_tuples
to the same thing.  n_live_tuples gets adjusted incrementally by
subsequent transactions, and it wouldn't be too surprising if it drifted
away from reality, but it's a bit hard to believe that it could get to be
off by 1000X.  Have you suppressed autovacuum on this table?

We have fooled around with the logic that maintains these numbers, so
maybe it was different in 9.6.9.

Anyway, to answer your question, I don't see anything in the current core
code that pays attention to n_live_tuples.  reltuples definitely does
matter to the planner, and some of the sibling counters like n_dead_tuples
drive autovacuum, but nothing is examining n_live_tuples AFAICS.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <1935.1554869432@sss.pgh.pa.us>
Permalink:  ../1935.1554869432@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1935.1554869432@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, sbranchaw@gmail.com
  Subject: Re: Does pg_stat_get_live_tuples() matter?
  In-Reply-To: <1935.1554869432@sss.pgh.pa.us>
  References: <CAB_myF4K=VFL=VF41k2=qNgTQ=r0AzojmBin=ejVHT9A-wat3A@mail.gmail.com> <1935.1554869432@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