pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matheus Alcantara <matheusssilv97@gmail.com>
To: Corey Huinker <corey.huinker@gmail.com>
To: Matheus Alcantara <matheusssilv97@gmail.com>
Cc: Etsuro Fujita <etsuro.fujita@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: pgsql-hackers@postgresql.org
Cc: jkatz@postgresql.org
Cc: nathandbossart@gmail.com
Subject: Re: Import Statistics in postgres_fdw before resorting to sampling.
Date: Wed, 07 Jan 2026 16:27:11 -0300
Message-ID: <DFILRUQ2L3AO.HWAH562SYHHS@gmail.com> (raw)
In-Reply-To: <CADkLM=exH-6QAZE9sLBGH=GPkfUUC=dXp6VvYfRkEfJfuKwPNA@mail.gmail.com>
References: <CADkLM=chrYAx=X2KUcDRST4RLaRLivYDohZrkW4LLBa0iBhb5w@mail.gmail.com>
	<CAExHW5seoMNjHiZge0O=p-oF6PGsY8om4VjpzTCBsaASXZC6Fw@mail.gmail.com>
	<CADkLM=feCJrEDWCOpoxxg58J_6zX6nv+BnXufUOEZuP7bYTCbg@mail.gmail.com>
	<CADkLM=d8+FwmbH0imhPOw=VGEASL4Q8tsCFjNcnfbU7sSWm0ig@mail.gmail.com>
	<CADkLM=cVc-KUAqcm1yoDkGwMrcgCvxY3WAMpaRZVLtO9sbc+kg@mail.gmail.com>
	<aPXaeowZ6RBPlsrD@paquier.xyz>
	<CADkLM=dSJk8h+14Wi7dGGcO1168R_nCGO2EHRTcC6b2Zu0rhpg@mail.gmail.com>
	<CAPmGK15Lk0ynP_b46sgfV1pmByzWUKVQoZBSV8fbN0rKb_6AnA@mail.gmail.com>
	<CADkLM=foU7yK1rfMzqTPiQtfEOGANAS9dHE5-Js6hEXmZiKfow@mail.gmail.com>
	<CADkLM=eDJiXe58+fXiFqp8Zyrh-E28mU11U53rVGjx0AQFzBKw@mail.gmail.com>
	<CAPmGK15jEDCeMXE=EEuA5-1tC2xg5WYSjWzPGpcz+udHBT4bUA@mail.gmail.com>
	<CADkLM=fRF2w-_fMyztS0R4e9YVH8tamHXMsBBVhFsSHoJKrKXg@mail.gmail.com>
	<CAPmGK17Dfjy_zLH1yjPqybpSueHWP7Gy_xBZXA2NpRso1qya7A@mail.gmail.com>
	<CADkLM=fb=FsBLqNc14-y4na57ypywZxYb4q-zrxcaY6qQW0B2Q@mail.gmail.com>
	<CADkLM=dfuT8YgXOyoXW7nuGdOFw-sYh2uR3hQS-N66Gj_k_ytw@mail.gmail.com>
	<CAPmGK17v-qJL5j2Z25jD33vKLyhAnNppYsy5UTbEAwAeBP=vGQ@mail.gmail.com>
	<CAPmGK15iR8M55_Fi6PZyvSH5-4B-R2n2YvvhRJB8Pm2cxxrF1w@mail.gmail.com>
	<CADkLM=cVZH+SDUuvsyMHzuWTK5XkK1i_L5dgTNrgRXWN1S-syQ@mail.gmail.com>
	<CAPmGK16AQzGsEe6pD7m42AO1KRCuXQu=U_abXaAf3juCS5U+mA@mail.gmail.com>
	<CADkLM=ezV0_oUCxK=A2TmaAuXvWs0+i-H8fSNU3BRY=dBuDhQQ@mail.gmail.com>
	<DFIGGS6XFI8O.1GL3RY3PO4AEP@gmail.com>
	<CADkLM=exH-6QAZE9sLBGH=GPkfUUC=dXp6VvYfRkEfJfuKwPNA@mail.gmail.com>

On Wed Jan 7, 2026 at 4:17 PM -03, Corey Huinker wrote:
>>
>> +
>> I don't think that it's good to make StatisticsAreImportable() routine
>> check if fetch_stats is enabled on foreign server/table options because
>> if so, every fdw implementation would need this same block of code and
>> also fdw implementations may forget or bypass these options which I
>> don't think that it would be a desired behavior. What about move this
>> check to analyze_rel()? Perhaps create a function that just check if the
>> fetch_stats is enabled.
>>
>
> StatisticsAreImportable() is a virtual function whose goal is to determine
> if this specific table supports stats exporting.
>
> postgresStatisticsAreImportable() is the postgres_fdw implementation of
> that virtual function.
>
> Any other FDWs that want to implement stats import will need to invent
> their own tests and configurations to determine if that is possible.
>
Ok, now I understand. I thought that fetch_stats and remote_analyze was
a generally fdw option and not only specific to postgres_fdw. Now I
understand that is up to the fdw implementation decide how this should
be enabled or disabled. Thanks for making it clear now.

>> If it returns true it means that the statistics
>> was imported successfully, otherwise if it returns false we could
>> fallback to table sampling as we already do today. ImportStatistics
>> could return false if the foreign server don't have statistics for the
>> requested table, even  after running ANALYZE if remote_analyze is true.
>>
>> Is that make sense? Any thoughts?
>>
>
> That sounds very similar to the design that was presented in v1.
>
Yeah, I think that my suggestion don't make sense, I miss understood the
feature. Sorry about the noise, I'll continue reviewing the v8 patch.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com






view thread (89+ messages)  latest in thread

Message-ID: <DFILRUQ2L3AO.HWAH562SYHHS@gmail.com>
Permalink:  ../DFILRUQ2L3AO.HWAH562SYHHS@gmail.com/
Also on:    postgresql.org/message-id/DFILRUQ2L3AO.HWAH562SYHHS@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: matheusssilv97@gmail.com, corey.huinker@gmail.com, etsuro.fujita@gmail.com, michael@paquier.xyz, ashutosh.bapat.oss@gmail.com, jkatz@postgresql.org, nathandbossart@gmail.com
  Subject: Re: Import Statistics in postgres_fdw before resorting to sampling.
  In-Reply-To: <DFILRUQ2L3AO.HWAH562SYHHS@gmail.com>
  References: <CADkLM=chrYAx=X2KUcDRST4RLaRLivYDohZrkW4LLBa0iBhb5w@mail.gmail.com> <CADkLM=eDJiXe58+fXiFqp8Zyrh-E28mU11U53rVGjx0AQFzBKw@mail.gmail.com> <CAPmGK15jEDCeMXE=EEuA5-1tC2xg5WYSjWzPGpcz+udHBT4bUA@mail.gmail.com> <CADkLM=fRF2w-_fMyztS0R4e9YVH8tamHXMsBBVhFsSHoJKrKXg@mail.gmail.com> <CAPmGK17Dfjy_zLH1yjPqybpSueHWP7Gy_xBZXA2NpRso1qya7A@mail.gmail.com> <CADkLM=fb=FsBLqNc14-y4na57ypywZxYb4q-zrxcaY6qQW0B2Q@mail.gmail.com> <CADkLM=dfuT8YgXOyoXW7nuGdOFw-sYh2uR3hQS-N66Gj_k_ytw@mail.gmail.com> <CAPmGK17v-qJL5j2Z25jD33vKLyhAnNppYsy5UTbEAwAeBP=vGQ@mail.gmail.com> <CAPmGK15iR8M55_Fi6PZyvSH5-4B-R2n2YvvhRJB8Pm2cxxrF1w@mail.gmail.com> <CADkLM=cVZH+SDUuvsyMHzuWTK5XkK1i_L5dgTNrgRXWN1S-syQ@mail.gmail.com> <CAPmGK16AQzGsEe6pD7m42AO1KRCuXQu=U_abXaAf3juCS5U+mA@mail.gmail.com> <CADkLM=ezV0_oUCxK=A2TmaAuXvWs0+i-H8fSNU3BRY=dBuDhQQ@mail.gmail.com> <DFIGGS6XFI8O.1GL3RY3PO4AEP@gmail.com> <CADkLM=exH-6QAZE9sLBGH=GPkfUUC=dXp6VvYfRkEfJfuKwPNA@mail.gmail.com> <DFILRUQ2L3AO.HWAH562SYHHS@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox