From: | Hari Krishna Sunder <hari(dot)db(dot)pg(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>, jian he <jian(dot)universality(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>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, alvherre(at)alvh(dot)no-ip(dot)org |
Subject: | Re: Statistics Import and Export |
Date: | 2025-05-14 20:30:48 |
Message-ID: | CAAeiqZ3BPCXziob2-Ldf15h0eS-0C6qbNoT3n5jiXEvMrjEW-w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Thanks Nathan.
Here is the patch with a comment.
On Wed, May 14, 2025 at 8:53 AM Nathan Bossart <nathandbossart(at)gmail(dot)com>
wrote:
> On Tue, May 13, 2025 at 05:01:02PM -0700, Hari Krishna Sunder wrote:
> > We found a minor issue when testing statistics import with upgrading from
> > versions older than v14. (We have VACUUM and ANALYZE disabled)
> > 3d351d916b20534f973eda760cde17d96545d4c4
> > <
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=3d351d916b20534f973eda760cde17d96545d4c4
> >
> > changed
> > the default value for reltuples from 0 to -1. So when such tables are
> > imported they get the pg13 default of 0 which in pg18 is treated
> > as "vacuumed and seen to be empty" instead of "never yet vacuumed". The
> > planner then proceeds to pick seq scans even if there are indexes for
> these
> > tables.
> > This is a very narrow edge case and the next VACUUM or ANALYZE will fix
> it
> > but the perf of these tables immediately after the upgrade is
> considerably
> > affected.
>
> There was a similar report for vacuumdb's new --missing-stats-only option.
> We fixed that in commit 9879105 by removing the check for reltuples != 0,
> which means that --missing-stats-only will process empty tables.
>
> > Can we instead use -1 if the version is older than 14, and reltuples is
> 0?
> > This will have the unintended consequence of treating a truly empty table
> > as "never yet vacuumed", but that should be fine as empty tables are
> going
> > to be fast regardless of the plan picked.
>
> I'm inclined to agree that we should do this. Even if it's much more
> likely that 0 means empty versus not-yet-processed, the one-time cost of
> processing some empty tables doesn't sound too bad. In any case, since
> this only applies to upgrades from <v14, that trade-off should dissipate
> over time.
>
> > PS: This is my first patch, so apologies for any issues with the patch.
>
> It needs a comment, but otherwise it looks generally reasonable to me after
> a quick glance.
>
> --
> nathan
>
Attachment | Content-Type | Size |
---|---|---|
0001-Stats-import-Fix-default-reltuples-on-versions-older.patch | application/octet-stream | 1.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Marcos Pegoraro | 2025-05-14 20:40:56 | Re: Better visualization of default values |
Previous Message | Mihail Nikalayeu | 2025-05-14 19:34:56 | Re: Small fixes needed by high-availability tools |