pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chao Li <li.evan.chao@gmail.com>
To: Corey Huinker <corey.huinker@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
Subject: Re: Import Statistics in postgres_fdw before resorting to sampling.
Date: Mon, 24 Nov 2025 17:25:13 +0800
Message-ID: <F9C73EF2-F977-46E4-9F61-B6CF72BF1A69@gmail.com> (raw)
In-Reply-To: <CADkLM=eDJiXe58+fXiFqp8Zyrh-E28mU11U53rVGjx0AQFzBKw@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>



> On Nov 23, 2025, at 15:27, Corey Huinker <corey.huinker@gmail.com> wrote:
> 
>   My apologies for the delayed response.
> 
> Valuable responses are worth waiting for.
> 
> I've reorganized some things a bit, mostly to make resource cleanup simpler. 
> <v4-0001-Add-remote-statistics-fetching-to-postgres_fdw.patch>


Few comments:

1 - commit message
```
effort and the user is better of setting fetch_stats to false for that
```

I guess “of” should be “off”

2 - postgres-fdw.sgml
```
+       server, determines wheter an <command>ANALYZE</command> on a foreign
```

Typo: wheter => whether 

3 - postgres-fdw.sgml
```
+       data sampling if no statistics were availble. This option is only
```

Typo: availble => available

4 - option.c
```
+		/* fetch_size is available on both server and table */
+		{"fetch_stats", ForeignServerRelationId, false},
+		{"fetch_stats", ForeignTableRelationId, false},
```

In the comment, I guess fetch_size should be fetch_stats.

5 - analyze.c
```
+			 * XXX: Should this be it's own fetch type? If not, then there might be
```

Typo: “it’s own” => “its own”

6 - analyze.c
```
+				case FDW_IMPORT_STATS_NOTFOUND:
+					ereport(INFO,
+							errmsg("Found no remote statistics for \"%s\"",
+								   RelationGetRelationName(onerel)));
```

`Found no remote statistics for \"%s\””` could be rephrased as `""No remote statistics found for foreign table \"%s\””`, sounds better wording in server log.

Also, I wonder if this message at INFO level is too noisy?

7 - postgres_fdw.c
```
+		default:
+			ereport(INFO,
+					errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+					errmsg("Remote table %s.%s does not support statistics.",
+						   quote_identifier(remote_schemaname),
+						   quote_identifier(remote_relname)),
+					errdetail("Remote relation if of relkind \"%c\"", relkind));
```

I think “if of” should be “is of”.

8 - postgres_fdw.c
```
+						errmsg("Attribute statistics found for %s.%s but no columns matched",
+							   quote_identifier(schemaname),
+							   quote_identifier(relname))));
```

Instead of using "%s.%s” and calling quote_identifier() twice, there is a simple function to use: quote_qualified_identifier(schemaname, relname).

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/









view thread (89+ messages)  latest in thread

Message-ID: <F9C73EF2-F977-46E4-9F61-B6CF72BF1A69@gmail.com>
Permalink:  ../F9C73EF2-F977-46E4-9F61-B6CF72BF1A69@gmail.com/
Also on:    postgresql.org/message-id/F9C73EF2-F977-46E4-9F61-B6CF72BF1A69@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: li.evan.chao@gmail.com, corey.huinker@gmail.com, etsuro.fujita@gmail.com, michael@paquier.xyz, ashutosh.bapat.oss@gmail.com
  Subject: Re: Import Statistics in postgres_fdw before resorting to sampling.
  In-Reply-To: <F9C73EF2-F977-46E4-9F61-B6CF72BF1A69@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> <F9C73EF2-F977-46E4-9F61-B6CF72BF1A69@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