Re: Import Statistics in postgres_fdw before resorting to sampling.

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, 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-01-07 02:18:04
Message-ID: CAPmGK16k0W82HvUhbgWt824ZnmnLYhbb49G7gxczAjoaGmz0kw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Matheus,

On Wed, Jan 7, 2026 at 6:38 AM Matheus Alcantara
<matheusssilv97(at)gmail(dot)com> wrote:
> + if (fdwroutine->ImportStatistics != NULL &&
> + fdwroutine->StatisticsAreImportable != NULL &&
> + fdwroutine->StatisticsAreImportable(onerel))
> + import_stats = true;
> + else
> + {
> + if (fdwroutine->AnalyzeForeignTable != NULL)
> + ok = fdwroutine->AnalyzeForeignTable(onerel,
> + &acquirefunc,
> + &relpages);
> +
> + if (!ok)
> + {
> + ereport(WARNING,
> + errmsg("skipping \"%s\" -- cannot analyze this foreign table.",
> + RelationGetRelationName(onerel)));
> + relation_close(onerel, ShareUpdateExclusiveLock);
> + return;
> + }
> + }
> +
> if (fdwroutine->AnalyzeForeignTable != NULL)
> ok = fdwroutine->AnalyzeForeignTable(onerel,
> &acquirefunc,
> &relpages);
>
> if (!ok)
> {
> ereport(WARNING,
> (errmsg("skipping \"%s\" --- cannot analyze this foreign table",
> RelationGetRelationName(onerel))));
> relation_close(onerel, ShareUpdateExclusiveLock);
> return;
> }
>
> It seems that we have the same code within the else branch after the if/else
> check, is this correct?

No. This should be something like the attached in [1]. (I didn't
look at the core changes in v6...)

Thanks!

Best regards,
Etsuro Fujita

[1] https://www.postgresql.org/message-id/CAPmGK17Dfjy_zLH1yjPqybpSueHWP7Gy_xBZXA2NpRso1qya7A%40mail.gmail.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-01-07 02:26:27 Fwd: pg18 bug? SELECT query doesn't work
Previous Message Masahiko Sawada 2026-01-07 02:14:44 Re: [PATCH] Fix replica identity mismatch for partitioned tables with publish_via_partition_root