Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNSpc-003Kjq-0k for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 09:26:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNSpa-0004OT-2d for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 09:25:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNSpa-0004OF-1g for pgsql-hackers@lists.postgresql.org; Mon, 24 Nov 2025 09:25:58 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vNSpY-001CYl-1L for pgsql-hackers@postgresql.org; Mon, 24 Nov 2025 09:25:58 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso4770436b3a.1 for ; Mon, 24 Nov 2025 01:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763976354; x=1764581154; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zEceM8KimQ00lyG7kn9Vfsve6fhRogb1fRE23T2Axdo=; b=luv+3LH61aJcl32TZF8HXnlLf03OjraOP/rKvfO06Nq0o/Y8JNr/Lgc2aEHFwwgZhW BFt9q7TPnQ+mg3wXBvomGY8JY9iAk26aQSQw9kZf2Ml5Zvii9Vw/DKN2BM3GOguwKUYg sb5sKI9vYXR89VVX09I9+CmohR/YFUWLxTRMrbPae7YM7GpxVPSJ1Dc4KWPaXR0BWQ4b 73G+YfNQK/jU0ekCn4QwxELipMyMouyT1Ebf9bQGOzPBwXSLSHKn6S1cg9EaiVXlJl7B adhQbuFOn05a0UldBI5gOPT2+aym8Uq4F2ahal48Spt/ElM1iRJO71JvfnF8+EmDSBO0 p5bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763976354; x=1764581154; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zEceM8KimQ00lyG7kn9Vfsve6fhRogb1fRE23T2Axdo=; b=EaQ19+gQv6Xsss1zrcF+i1DrMkPkSRQQIMpymCxhkTZO9r/pwE1kQbK38QzygldwBb /mesIuyh6FrgIxw5U7sMG3nx6zaCF6++JQw8EXsiCL2QhT1J5RIX3wr4fCnzsXUC0mue pUExtQ3VIRi3lJHxeDvJHvNF8ZsNwRYQoB3RPfPAo1y3GtSPJVOk4HXrpmL3DU+/0AKI YmKPsNACmiQjtj1xQdvJzMwC0CAsVSDOJWSBHu95go6flqXHnBYnziI3E8LMv7ld1Hvm j+egOE6buchDYztXhQrBxIH6jySFe6WiW0DEX3ZrZsDKn1sj46nHuPgZnm9O3JyEkHca oTDA== X-Forwarded-Encrypted: i=1; AJvYcCWGxmOPNxwMv6S4pwd3DAnwW1rfAXX62N1M2LhNolk0tROuDXqYgZfahy5fMvFbGxDRtbokSosg1zsDOD8t@postgresql.org X-Gm-Message-State: AOJu0YxbQAOy7egWhrmnV7qQx2h0R4MWdNgGp2p2/IoMzx8n9ecUlf21 IPpcfTmyjet1qTMvfKuafP4SoKbWkbNy0eIYTeEn6buOFooAXXv6/ogU X-Gm-Gg: ASbGncswfI3axbvDHTF2u51vk72MiXu5R7xKnsDHjhQFVandB64epTOuBiLjb8qoEr4 7bqE4TNIDmwEGMuro1iP/WlSaR3EgxEB/W/v9MFICajGxVDzkw3OmBl+5ZpTsOp/7UdrpMRqxLy 6EIW4qr0OXk93PAKoxKoAUPUPFOAiiGt0DqDvErcuYKHd5tapAG4X3aJO8cpbcz5aXfHLVl5psE DopMVzltA+N/0vuZMTLYaD8ufmpbgkIUgk8wNZUkpBc4KOy78uciqmMmeiphYPvfRPIEyusiCVc hsss/J+Lu8ozrZdQrcEVMehroWJL1C3a5lyMcpRJIOvsmyzzJYg+5iQyB8/8Ym+GU3c0RP9rpSO 2zEQiJ8D2/zMZ4Y7nSwO1W925z0d+PfelEwmgBCYnAIZmXUBkS/yrMFCJ9i6JNV7AtrhUiSKoIv vuaAe5SzJJG9GbfqrwHtE= X-Google-Smtp-Source: AGHT+IHgaogqofwHEw/vMZ3JQPRDnu5oHYzPsABiFeARE7fPbhX88Q+Mw95w4KUkY2HQ+ZVdL+vVQA== X-Received: by 2002:a05:6a20:e211:b0:355:9965:1712 with SMTP id adf61e73a8af0-3614ee47ec8mr12057679637.55.1763976354012; Mon, 24 Nov 2025 01:25:54 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bd760ac6354sm12554112a12.24.2025.11.24.01.25.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Nov 2025 01:25:53 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Import Statistics in postgres_fdw before resorting to sampling. From: Chao Li In-Reply-To: Date: Mon, 24 Nov 2025 17:25:13 +0800 Cc: Etsuro Fujita , Michael Paquier , Ashutosh Bapat , pgsql-hackers@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Corey Huinker X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Nov 23, 2025, at 15:27, Corey Huinker = wrote: >=20 > My apologies for the delayed response. >=20 > Valuable responses are worth waiting for. >=20 > I've reorganized some things a bit, mostly to make resource cleanup = simpler.=20 > Few comments: 1 - commit message ``` effort and the user is better of setting fetch_stats to false for that ``` I guess =E2=80=9Cof=E2=80=9D should be =E2=80=9Coff=E2=80=9D 2 - postgres-fdw.sgml ``` + server, determines wheter an ANALYZE on a = foreign ``` Typo: wheter =3D> whether=20 3 - postgres-fdw.sgml ``` + data sampling if no statistics were availble. This option is = only ``` Typo: availble =3D> 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: =E2=80=9Cit=E2=80=99s own=E2=80=9D =3D> =E2=80=9Cits own=E2=80=9D 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\=E2=80=9D=E2=80=9D` could be = rephrased as `""No remote statistics found for foreign table = \"%s\=E2=80=9D=E2=80=9D`, 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 =E2=80=9Cif of=E2=80=9D should be =E2=80=9Cis of=E2=80=9D. 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=E2=80=9D 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/