Re: Import Statistics in postgres_fdw before resorting to sampling.

Etsuro Fujita <etsuro.fujita@gmail.com>

From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Michael Paquier <michael@paquier.xyz>, pgsql-hackers@postgresql.org, jkatz@postgresql.org, nathandbossart@gmail.com
Date: 2026-04-07T10:09:46Z
Lists: pgsql-hackers

Attachments

On Sun, Apr 5, 2026 at 8:05 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
> On Sat, Apr 4, 2026 at 1:01 AM Corey Huinker <corey.huinker@gmail.com> wrote:

> >> One thing I'm wondering is: we should rename ImportStatistics to
> >> ImportForeignStatistics, for consistency with ImportForeignSchema?
>
> > ImportForeignStatistics makes sense to me.
>
> Will rename.

Done.

> >> Also, we should rename fetch_stats to import_stats, for consistency
> >> with eg, import_default?
>
> > restore_stats is probably the better name, given that it is calling the pg_restore_*() functions.
>
> That sounds better, so will rename.

Done.

Here are other changes:

* I removed the implementation details from the docs in
postgres-fdw.sgml, as I think it is overly technical for
postgres-fdw.sgml, which is intended for end users.  Also, I added a
note about resorting to sampling if stats import failed, and another
note about the user's responsibility to ensure that remote stats are
up-to-date.

* I added the docs about the new callback routine to fdwhandler.sgml.

* I added/tweaked comments.

* I Added one more test case.

* I did further cleanup and editorialization.

I think the patch is committable, so I will push it if no objections.
(Maybe we could add/improve some more comments, but I think we could
do that later if needed.)

Best regards,
Etsuro Fujita

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. postgres_fdw: Replace buffers in RemoteAttributeMapping with pointers.

  2. Add support for importing statistics from remote servers.