Re: Statistics Import and Export: difference in statistics dumped

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: Statistics Import and Export: difference in statistics dumped
Date: 2025-03-07 19:14:08
Message-ID: 1116282.1741374848@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> Sounds good. I will commit something like the v2 patch then soon, and
> if we need a different condition we can change it later.

Sadly, this made things worse not better: crake is failing
cross-version-upgrade tests again [1], with dump diffs like

@@ -270836,8 +270836,8 @@
--
SELECT * FROM pg_catalog.pg_restore_relation_stats( 'version', '000000'::integer,
'relation', 'public.hash_f8_index'::regclass,
- 'relpages', '66'::integer,
- 'reltuples', '10000'::real,
+ 'relpages', '0'::integer,
+ 'reltuples', '-1'::real,
'relallvisible', '0'::integer
);

I think what is happening is that the patch shut off CREATE
INDEX's update of not only the table's stats but also the
index's stats. This seems unhelpful: the index's empty
stats can never be what's wanted.

We could band-aid over this by making AdjustUpgrade.pm
lobotomize the comparisons of all three stats fields,
but I think it's just wrong as-is. Perhaps fix by
checking the relation's relkind before applying the
autovacuum heuristic?

regards, tom lane

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=crake&dt=2025-03-07%2018%3A19%3A14

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2025-03-07 19:14:52 Re: Simplify the logic a bit (src/bin/scripts/reindexdb.c)
Previous Message Álvaro Herrera 2025-03-07 19:01:20 Re: Simplify the logic a bit (src/bin/scripts/reindexdb.c)