Re: Extended Statistics set/restore/clear functions.

Corey Huinker <corey.huinker@gmail.com>

From: Corey Huinker <corey.huinker@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tomas Vondra <tomas@vondra.me>, jian he <jian.universality@gmail.com>, pgsql-hackers@lists.postgresql.org, tgl@sss.pgh.pa.us
Date: 2025-11-10T05:33:40Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add test doing some cloning of extended statistics data

  2. Add test for pg_restore_extended_stats() with multiranges

  3. Add support for "mcv" in pg_restore_extended_stats()

  4. Include extended statistics data in pg_dump

  5. Add support for "dependencies" in pg_restore_extended_stats()

  6. Add test for MAINTAIN permission with pg_restore_extended_stats()

  7. Add pg_restore_extended_stats()

  8. Add routine to free MCVList

  9. Improve pg_clear_extended_stats() with incorrect relation/stats combination

  10. Add pg_clear_extended_stats()

  11. Introduce routines to validate and free MVNDistinct and MVDependencies

  12. Fix typo in stat_utils.c

  13. Move attribute statistics functions to stat_utils.c

  14. Improve error messages of input functions for pg_dependencies and pg_ndistinct

  15. Improve test output of extended statistics for ndistinct and dependencies

  16. Fix some compiler warnings

  17. Add input function for data type pg_dependencies

  18. Add input function for data type pg_ndistinct

  19. Rework output format of pg_dependencies

  20. Rework output format of pg_ndistinct

  21. Fix comments of output routines for pg_ndistinct and pg_dependencies

  22. Move code specific to pg_dependencies to new file

  23. Move code specific to pg_ndistinct to new file

  24. Document some structures in attribute_stats.c

  25. Fix FATAL message for invalid recovery timeline at beginning of recovery

Attachments

>
> Another thing that may be worth doing is pushing the names of the keys
> and some its the JSON meta-data shaping the object into a new header
> than can be loaded by both the backend and the frontend.  It would be
> nice to not hardcode this knowledge in a bunch of places if we finish
> by renaming these attributes.
>

It may not be quite what you wanted, but the attribute names are now static
constants in the new adt c files. It's possible/probable that you wanted
them in some header file, but so far I haven't had to create any new header
files, but that can be done if desired.

Yeah, right.  Thanks.  The parsing pieces seem like pieces worth their
> own file.
>

That's done in the 0008-0009 patches. If I was starting from scratch, I
would have moved the pre-existing in/out/send/recv functions to their own
files in their own patches before changing the output format, but tacked on
at the end like they are it's easier to see what the changes were, and the
patches will probably get squashed together anyway.


> > The functions in question are needed because the exprs value is itself an
> > array of partly-filled-out pg_attribute tuples, so it's common to those
> two
> > needs, but specific to stats about attributes. Maybe we need an
> > attr_stats_utils.h?
>
> Hmm, maybe.  I'd be OK to revisit these structures once we're happy
> with the in/out structures.  That would be a good start point before
> working on the SQL functions and the dump/restore bits in more
> details.
>

In addition to the changes detailed above, I fixed a few typos and
incorporated the v8 change.