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

From Ashutosh Bapat
Subject Re: Import Statistics in postgres_fdw before resorting to sampling.
Date
Msg-id CAExHW5sV1tKES6A=T-auzHtoOMKO-wurUqEHFbOgZJ-jBnxuxw@mail.gmail.com
Whole thread Raw
In response to Re: Import Statistics in postgres_fdw before resorting to sampling.  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: Import Statistics in postgres_fdw before resorting to sampling.
List pgsql-hackers
On Wed, Jan 7, 2026 at 11:34 AM Corey Huinker <corey.huinker@gmail.com> wrote:

>
> Anyway, here's v8, incorporating the documentation feedback and Matheus's notes.

I went through the patches. I have one question: The column names of
the foreign table on the local server are sorted using qsort, which
uses C sorting. The column names the result obtained from the foreign
server are sorted using ORDER BY clause. If the default collation on
the foreign server is different from the one used by qsort(), the
merge sort in import_fetched_statistics() may fail. Shouldn't these
two sorts use the same collation?

Some minor comments

/* avoid including explain_state.h here */
typedef struct ExplainState ExplainState;
-

unintended line deletion?

fetch_remote_statistics() fetches the statistics twice if the first
attempt fails. I think we need same check after the second attempt as
well. The second attempt should not fail, but I think we need some
safety checks and Assert at least, in case the foreign server
misbehaves.

--
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: Pasword expiration warning
Next
From: Chao Li
Date:
Subject: Re: GIN pageinspect support for entry tree and posting tree