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: maxim.boguk@gmail.com
Subject: BUG #17205: pg_class.reltuples vakue wrong for brin indexes after vacuum (by many orders of magnitude)
Date: Thu, 30 Sep 2021 07:19:53 +0000
Message-ID: <17205-42b1d8f131f0cf97@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      17205
Logged by:          Maxim Boguk
Email address:      maxim.boguk@gmail.com
PostgreSQL version: 13.4
Operating system:   Linux
Description:        

Hi,

pg_class.reltuples wrong by many order of magnitude after (auto)vacuum table
for brin indexes.
Analyze table set corrent value back, and following vacuum set it wrong
again (so correctness of value in production db depend on exact sequence of
autovacuu/autoanalyze runs).

Test case:

mboguk=# create table t (id integer);
CREATE TABLE
mboguk=# insert into t select id from generate_series(1, 10000000);

mboguk=# insert into t select id from generate_series(1, 10000000) as
g(id);
INSERT 0 10000000

mboguk=# create index t_brin on t using BRIN(id);
CREATE INDEX

mboguk=# vacuum ANALYZE t;
VACUUM

mboguk=# select reltuples from pg_class where relname='t_brin';
  reltuples   
--------------
 9.999977e+06
(1 row)

mboguk=# vacuum t;
VACUUM
mboguk=# select reltuples from pg_class where relname='t_brin';
 reltuples 
-----------
       345
(1 row)

mboguk=# analyze t;
ANALYZE
mboguk=# select reltuples from pg_class where relname='t_brin';
  reltuples   
--------------
 9.999977e+06
(1 row)

mboguk=# vacuum t;
VACUUM
mboguk=# select reltuples from pg_class where relname='t_brin';
 reltuples 
-----------
       345
(1 row)
And so on...

Tested on 12.* and 13.* versions.

Kind Regards,
Maksym



view thread (2+ messages)  latest in thread

Message-ID: <17205-42b1d8f131f0cf97@postgresql.org>
Permalink:  ../17205-42b1d8f131f0cf97@postgresql.org/
Also on:    postgresql.org/message-id/17205-42b1d8f131f0cf97@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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, maxim.boguk@gmail.com
  Subject: Re: BUG #17205: pg_class.reltuples vakue wrong for brin indexes after vacuum (by many orders of magnitude)
  In-Reply-To: <17205-42b1d8f131f0cf97@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