Re: Extended Statistics set/restore/clear functions.

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Tender Wang <tndrwang(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Extended Statistics set/restore/clear functions.
Date: 2026-01-27 04:55:06
Message-ID: aXhFKleXWlooHcy3@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 26, 2026 at 04:42:38PM +0900, Michael Paquier wrote:
> Another side note: I am not sure how the CI or the buldfarm did not
> notice that, but I've found a bug in the tuple initialization logic
> while reviewing more the code, fixed in 114e84c532d1. Perhaps my
> build environment was more efficient in detecting that.

So, I have done more work on all that, and extracted two more pieces,
applying them:
- The bits for dependencies in the restore function, .
- The pg_dump bits for dependencies and n_distinct, as of
c32fb29e979d. It was sad here that your posted patch did not use the
keys of statistics_format.h. A comment was also missing in
AdjustUpgrade.pm, where the code will be able to handle the "version"
tag included in the dumps.

Another thing that I strongly suspect is going to break in the
buildfarm are the cross-version upgrades, because the format of
the pg_dependencies and pg_ndistinct is not completely portable.
While dumping the data for versions older than v18, there are a couple
spaces added due to the way the JSON data is translated. A similar
issue unfortunately exists for the rounding of the degree numbers in
dependencies. I am not sure if this is going to break, but if this
breaks I have prepared the following insurance policy for
AdjustUpgrade.pm:
$dump =~ s {\n(\s+'n_distinct',) '.*'::pg_ndistinct}
{\n$1 'EXT_STATS_DATA'::pg_ndistinct}mg;
$dump =~ s {\n(\s+'dependencies',) '.*'::pg_dependencies}
{\n$1 'EXT_STATS_DATA'::pg_dependencies}mg;

This is a filter similar to the "version" field, except that we would
replace all the contents of the pg_ndistinct and pg_dependencies
values inside single quotes, protecting the dump comparisons for the
new and old versions. Let's see first what the buildfarm says and if
I need to pull this switch.

And it means that at this point we are feature-complete for these two
stats kinds, so there will be at least something for this release even
if MCV and expressions don't make it. Still, the other pieces should
be slightly easier to integrate now that the core parts have been
added.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message VASUKI M 2026-01-27 05:11:09 Re: Optional skipping of unchanged relations during ANALYZE?
Previous Message p.gilev 2026-01-27 04:33:59 Make T_CoalesceExpr executable on a foreign server