| From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| 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>, Tomas Vondra <tomas(at)vondra(dot)me> |
| Subject: | Re: Add expressions to pg_restore_extended_stats() |
| Date: | 2026-03-05 20:20:07 |
| Message-ID: | CADkLM=f-S2ySFBQWsBVc9k3fPAteRCOYOKdhEsZ5NE0_8SSqew@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Mar 4, 2026 at 5:29 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> On Wed, Mar 04, 2026 at 05:05:55PM -0500, Corey Huinker wrote:
> > 5. Generate the column list of the view (or set difference queries) with
> a
> > \gexec query that filters out the oids.
> >
> > All of these things are sliiightly hacky, but if we settle on one pattern
> > that will allow us to use the pattern in multiple places and thus reduce
> > surprise to the reader.
>
> I am not sure which one would be the best fit, TBH. To me, it depends
> mostly on clarity and how easier it becomes to maintain these tests.
> Perhaps I would have a slight preference on the views with quals based
> on the object names. As long as we don't maintain the same
> complicated queries more than once, I'm basically fine with any
> solution. Using json for this purpose feels a bit too much artistic.
> --
> Michael
>
Here's a proof of concept for just the pg_statistic checks. The basic
structure is:
1. Create a VIEW that has only the columns we want to set-difference, in
the datatype we want to difference them. The view will never hold data, we
just want it for the datatype (t).
2. Create a FUNCTION that fetched the stats for a given object (in this
case a table or index), keeping only the columns found in (t).
3. Another FUNCTION that takes two object names as parameters, does the
A-B,B-A set difference operators on them, and returns that as a set of
(relname,(t)).
4. The A-B,B-A tests then become just one call to that set_difference
function.
If this seems more elegant than what we have now, I'll write up a formal
patch for the three set-difference types (attstats, extended, extended
exprs).
| Attachment | Content-Type | Size |
|---|---|---|
| just_pg_statistic_set_difference_tests.diff | text/x-patch | 8.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matthias van de Meent | 2026-03-05 20:23:12 | Re: Why clearing the VM doesn't require registering vm buffer in wal record |
| Previous Message | Andres Freund | 2026-03-05 20:16:28 | Re: Why clearing the VM doesn't require registering vm buffer in wal record |