Re: Import Statistics in postgres_fdw before resorting to sampling. - Mailing list pgsql-hackers

From Etsuro Fujita
Subject Re: Import Statistics in postgres_fdw before resorting to sampling.
Date
Msg-id CAPmGK16k0W82HvUhbgWt824ZnmnLYhbb49G7gxczAjoaGmz0kw@mail.gmail.com
Whole thread Raw
In response to Re: Import Statistics in postgres_fdw before resorting to sampling.  ("Matheus Alcantara" <matheusssilv97@gmail.com>)
List pgsql-hackers
Hi Matheus,

On Wed, Jan 7, 2026 at 6:38 AM Matheus Alcantara
<matheusssilv97@gmail.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



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [PATCH] Fix replica identity mismatch for partitioned tables with publish_via_partition_root
Next
From: Richard Guo
Date:
Subject: Fwd: pg18 bug? SELECT query doesn't work