Re: Import Statistics in postgres_fdw before resorting to sampling.

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers(at)postgresql(dot)org, jkatz(at)postgresql(dot)org, nathandbossart(at)gmail(dot)com
Subject: Re: Import Statistics in postgres_fdw before resorting to sampling.
Date: 2026-04-05 11:05:42
Message-ID: CAPmGK15kq8L51wKuZKC9sCbfUNVcNwLTqi55nimgD1Jz3C-3vQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 4, 2026 at 1:01 AM Corey Huinker <corey(dot)huinker(at)gmail(dot)com> wrote:
>>
>> * As above, I think we should disable this feature by default for now,
>> so I modified the patch as such.

> +1 so long as it doesn't paint us into a corner.

Given that we can't guarantee the freshness, I think that that's the
only choice.

>> * You are defining a remote query per version at the top of the file
>> that is used in fetch_attstats, but I think that that reduces
>> readability, making maintenance hard, so I modified that function to
>> build the query dynamically in it, as I proposed before. I also
>> modified that function to use PQsendQuery, not PQsendQueryParams, as
>> in fetch_relstats, for efficiency.

> I'm curious, is the efficiency of PQsendQuery over PQsendQueryParams that significant?

No, it isn't, but note that PQsendQuery uses simple query protocol
while PQsendQueryParams uses extended query protocol, and that the
overhead incurred by the former protocol is smaller than that by the
latter protocol, so it's better to use PQsendQuery here.

>> * I fixed a minor bug I noticed while adding those tests.
>>
>> * I did some cleanup and editorialization including re-ordering
>> functions in logical order.

> This was momentarily confusing as I apply your patch to a separate branch and then compare whole branches, but it checks out.

Sorry, but I believe that that makes the code easy to read.

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

> ImportForeignStatistics makes sense to me.

Will rename.

>> 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.

Thanks for reviewing!

Best regards,
Etsuro Fujita

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2026-04-05 11:20:28 Re: Better shared data structure management and resizable shared data structures
Previous Message Heikki Linnakangas 2026-04-05 10:03:49 Re: Better shared data structure management and resizable shared data structures