| 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-03-12 11:02:43 |
| Message-ID: | CAPmGK17_g=iV+krUxxfpUfP1MZLm_-DGy7ZCgRQRxz48sJgvmw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sun, Jan 18, 2026 at 11:53 AM Corey Huinker <corey(dot)huinker(at)gmail(dot)com> wrote:
> Changes in this release, aside from rebasing:
>
> - The generic analyze and fdw.h changes are in their own patch (0001) that ignores contrib/postgres_fdw entirely.
> - The option for remote_analyze has been moved to its own patch (0003).
Thanks for splitting the patch! That makes reviewing easy!
> - The errors raised are now warnings, to ensure that we can always fall back to row sampling.
Falling back to sampling improves the usability, so I don't object to
adding it anymore, but I'm concerned about changes made to the error
handling of libpq functions in fetch_relstats() and fetch_attstats(),
like this bit in the former function:
+ if (!PQsendQueryParams(conn, sql, 2, NULL, params, NULL, NULL, 0))
+ {
+ pgfdw_report(WARNING, NULL, conn, sql);
+ return NULL;
+ }
+
+ res = pgfdw_get_result(conn);
+
+ if (res == NULL
+ || PQresultStatus(res) != PGRES_TUPLES_OK
+ || PQntuples(res) != 1
+ || PQnfields(res) != RELSTATS_NUM_FIELDS
+ || PQgetisnull(res, 0, RELSTATS_RELKIND))
+ {
+ pgfdw_report(WARNING, res, conn, sql);
+ PQclear(res);
+ return NULL;
+ }
By the errors-to-warnings change, even when those libpq functions
fail, we fall back to the normal ANALYZE processing, but I don't think
that that is OK, because if those functions fail for some reasons
(network-related issues like network disconnection or memory-related
issues like out of memory), then libpq functions called later for the
normal processing would also be likely to fail for the same reasons,
causing the same failure again, which I don't think is good. To avoid
that, when libpq functions in fetch_relstats() and fetch_attstats()
fail, shouldn't we just throw an error, as before?
Best regards,
Etsuro Fujita
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Eduard Stepanov | 2026-03-12 11:13:38 | Re: BUG: ReadStream look-ahead exhausts local buffers when effective_io_concurrency>=64 |
| Previous Message | Nazir Bilal Yavuz | 2026-03-12 10:59:53 | Re: Speed up COPY FROM text/CSV parsing using SIMD |