Re: Extended Statistics set/restore/clear functions.

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, jian he <jian(dot)universality(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, pgsql-hackers(at)lists(dot)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: Extended Statistics set/restore/clear functions.
Date: 2025-11-26 09:21:46
Message-ID: CADkLM=ckVb6AvfTsN=W3Z+Hqy9bzhh-quRsJOy_tzY-zUqWb9A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 25, 2025 at 11:14 PM Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
wrote:

>
>> I don’t see any of my comments are addressed in v18.
>>
>>
> My apologies. My v17 focused entirely on the input functions, as those
> were receiving the vast majority of the attention. Now that those are out
> of the way (Thanks Michael!) I can address those issues.
>

Paraphrasing the "quotes" here for brevity...

> Several functions are made external visible, they are all renamed with
adding a prefix “statatt_”, why text_to_stavalues is an exception?

Michael had specifically said that one didn't need to be renamed. I suppose
statatt_import_stavalues() might be a good name for it. It *is* specific to
attribute stats, though that definition also applies to the attribute stats
nested in the stxdexprs of extended stats. I have no strong opinion on the
matter.

> This MVDependency * can be const.

+1

> static void
> upsert_pg_statistic_ext_data(Datum *values, bool *nulls, bool *replaces)
> {
> ```

> This function pass values, nulls and replaces to heap_modify_tuple() and
heap_form_tuple(),
> the both functions take all const pointers as parameters.
> So, here values, nulls and replaces can all be const.
I find your argument here persuasive enough to override Michael's
previously stated non-excitement.

> ...the two NULL_FRAC questions

Yes, fixed.

> import_mcvlist is declared twice, looks like a copy-paste mistake.

That or a rebase/apply gone wrong. Fixed.

> PREPQUERY_DUMPEXTSTATSSTATS weird, suggest PREPQUERY_DUMPEXTSTATSDATA

Awkward names are almost inevitable when talking about the statistics
associated with an object of type "statistics".

There was a debate about whether statistics were data or not, and I'd
rather not restart that, so I went with PREPQUERY_DUMPEXTSTATSOBJSTATS for
now.

Incorporated these fixes, and some other lessons learned.

Attachment Content-Type Size
v19-0001-Expose-attribute-statistics-functions-for-use-in.patch application/octet-stream 10.8 KB
v19-0002-Add-extended-statistics-support-functions.patch application/octet-stream 167.0 KB
v19-0003-Include-Extended-Statistics-in-pg_dump.patch application/octet-stream 13.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2025-11-26 09:39:25 Refactoring: Use soft error reporting for *_opt_overflow functions of date/timestamp
Previous Message Dewei Dai 2025-11-26 09:14:52 Re: Re: Serverside SNI support in libpq