pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: daveg@sonic.net
Subject: BUG #15005: ANALYZE can make pg_class.reltuples inaccurate.
Date: Thu, 11 Jan 2018 11:12:54 +0000
Message-ID: <20180111111254.1408.8342@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15005
Logged by:          David Gould
Email address:      daveg@sonic.net
PostgreSQL version: 10.1
Operating system:   Linux
Description:        

ANALYZE can make pg_class.reltuples wildly inaccurate compared to the
actual
row counts for tables that are larger than the default_statistics_target.

Example from one of a clients production instances:

# analyze verbose pg_attribute;
INFO:  analyzing "pg_catalog.pg_attribute"
INFO:  "pg_attribute": scanned 30000 of 24519424 pages, containing 6475 live
rows and 83 dead rows; 6475 rows in sample, 800983035 estimated total
rows.

This is a large complex database -- pg_attribute actually has about five
million rows and needs about one hundred thouand pages. However it has
become extremely bloated and is taking 25 million pages (192GB!), about
250
times too much. This happened despite aggressive autovacuum settings and a
periodic bloat monitoring script. Since pg_class.reltuples was 800
million,
our bloat monitoring script did not detect that this table was bloated and
autovacuum did not think it needed vacuuming.
 
When reltuples is very large compared to the actual row count it causes
problems:

- Bad input to the query planner.
- Prevents autovacuum from processing large bloated tables because
  autovacuum_scale_factor * reltuples is large enough the threshold is
rarely
  reached.
- Decieves bloat checking tools that rely on the relationship of relpages
  to reltuples*average_row_size.

-dg




view thread (6+ messages)  latest in thread

Message-ID: <20180111111254.1408.8342@wrigleys.postgresql.org>
Permalink:  ../20180111111254.1408.8342@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20180111111254.1408.8342@wrigleys.postgresql.org

 · 

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-bugs@postgresql.org
  Cc: noreply@postgresql.org, daveg@sonic.net
  Subject: Re: BUG #15005: ANALYZE can make pg_class.reltuples inaccurate.
  In-Reply-To: <20180111111254.1408.8342@wrigleys.postgresql.org>
  References: <20180111111254.1408.8342@wrigleys.postgresql.org>

* 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