Re: Does pg_stat_get_live_tuples() matter?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sherrylyn Branchaw <sbranchaw(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Does pg_stat_get_live_tuples() matter?
Date: 2019-04-10 04:10:32
Message-ID: 1935.1554869432@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sherrylyn Branchaw <sbranchaw(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jess Wren 2019-04-10 08:57:22 Re: How to use full-text search URL parser to filter query results by domain name?
Previous Message Igal Sapir 2019-04-10 04:01:13 Re: Unable to Vacuum Large Defragmented Table