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 1vdZBk-002HOx-1C for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jan 2026 19:27:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdZBj-00FFOl-0Q for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jan 2026 19:27:23 +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 1vdZBi-00FFOd-2W for pgsql-hackers@lists.postgresql.org; Wed, 07 Jan 2026 19:27:23 +0000 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdZBe-005899-2l for pgsql-hackers@postgresql.org; Wed, 07 Jan 2026 19:27:22 +0000 Received: by mail-vs1-xe30.google.com with SMTP id ada2fe7eead31-5dd88eef2f3so877210137.3 for ; Wed, 07 Jan 2026 11:27:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767814036; x=1768418836; darn=postgresql.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s2JmXmJ3REBysjU+BAdyfEHbyXr6Rnd+ekFZ2hBgCZY=; b=iYV588mwlA4TNw9YSkfK8Vw987pxIpQPKoKW5eDVEfd1GhWlTz88xiZpxLRIoyYYKX 92akuyAWY9z7xiaeQi9BMfCDnOW/oRPT8RkNzlsfBOegemKabVNxf90k0W9fIxolkINV vTLVzXJqqfTkXF33RjuhGU+GIc/CqxJJ4R5+bMEt/XjJFNMrrH1t7GJ9ma9jXuFvTOCI woDHRc57PkU+TdL399mXVCFIjV2hEs4xDaTojoQl3fOBJKqE4+uQRUM57IwMtolC7p0M TeNpXZZe/c27xvG3kT9SXb19/N4/jWPE4jBHa1I42CsIj1na6xdYP7A/88PZgdoMFJxj oMVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767814036; x=1768418836; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=s2JmXmJ3REBysjU+BAdyfEHbyXr6Rnd+ekFZ2hBgCZY=; b=J/DPp2kOgPxvqa8pqS9r1ov117PNSZprs8Rit44U2HftZ5NcYPN2dHtEb6CBiqZxjB iV03bB4WNpMb3suy9rnURq40haTx1Cm8yYG5rwMESJeWiBL3U7/tnTPgkaPDaUA1h/+D m9Je3pK2eqUAEfbYKvCtJ/uIKeUvLNojN3U9BiQ5HS7GXCTPibrwcriX6yRk5O0XdGrn 4tTFRApOT0TU497EllFIJH2urNWySJmEgoO1yEnNWXOgf/WkKlMjzamjO4GVaA0sfY/9 i+1x/ozjGvbdeannu2HnVxsTLZlbZ1Pq8JSv2Gh0o9mSDI04R4izLw+mm628Ba2ntuTN gQvg== X-Forwarded-Encrypted: i=1; AJvYcCVhGs8q3oaZ0upjoq+ee5siA4PZ/2TI+YiWOj/vPtSJ9+izKjoewnXnHgu7CUn3wNnUodcv63D9UnJAco2z@postgresql.org X-Gm-Message-State: AOJu0Yy7cdpGTkhwijulymwT1VwUdPSgmb3fG/I82g7xJ3fojCN0JUdX PN1jIi33ksgLd77+xBEpsIpjcsW2wFnv141f39U5Fu1jnsjQzsEMsibQ X-Gm-Gg: AY/fxX6B4C8AdMIwfIZqcwT5grEknearurAIQl+Nz80R2ojB2QjGJ8sLU1hpXEzpdLf m7f7nEXA3eNouV5TkLXZa4QRoVvL/ZPP5KTBG2rx4eBIaAvookazc6GfEEbR8S2ZO0NyIoU5m2H x9RkoJ96mXuU/+1gtYdM3KtJ5xkZhAP6mmjhy9UET9XrA9k6X9YYRMbc65xKtb5bL7uTF9ZDP93 O57GWxs66dJlL2AUWPREU+j1jGoR3IvFLv2MvkCeIxbr/IIaOA6xJHiWuH8HulGNFWYVPEkhXCT 7DZw4oL67vTvAc2BzTiImFG/gylwfteQsVI2mXp7nUpOVDWHhCJ7XDE1Z2XnITWHGBFnf9A9ATp 0am5rWehQSDaEDSQrn4cxkz6t+XqaCvrN7xOx7yf4bZKC9hxZZrf2Khqnth4CdynxEeQiTXup3W wL8N204863dnRlZgPbCNIvCeW/UIxjQE1VNA== X-Google-Smtp-Source: AGHT+IHZ6qF4I+EBxwRjRa/c+xKw9M5UeZOSD0NdJTgIQX5RF36PXzrLeSJ6frB6QFnXNjYdqW79PQ== X-Received: by 2002:a05:6102:3c8a:b0:5df:8f4:61e6 with SMTP id ada2fe7eead31-5ecb69555admr1324561137.32.1767814036095; Wed, 07 Jan 2026 11:27:16 -0800 (PST) Received: from localhost ([2804:14d:328a:a59c:4934:3e02:ac25:9aec]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-944124c087bsm3711195241.12.2026.01.07.11.27.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jan 2026 11:27:15 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 07 Jan 2026 16:27:11 -0300 Message-Id: To: "Corey Huinker" , "Matheus Alcantara" Cc: "Etsuro Fujita" , "Michael Paquier" , "Ashutosh Bapat" , , , Subject: Re: Import Statistics in postgres_fdw before resorting to sampling. From: "Matheus Alcantara" X-Mailer: aerc 0.21.0 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed Jan 7, 2026 at 4:17 PM -03, Corey Huinker wrote: >> >> + >> I don't think that it's good to make StatisticsAreImportable() routine >> check if fetch_stats is enabled on foreign server/table options because >> if so, every fdw implementation would need this same block of code and >> also fdw implementations may forget or bypass these options which I >> don't think that it would be a desired behavior. What about move this >> check to analyze_rel()? Perhaps create a function that just check if the >> fetch_stats is enabled. >> > > StatisticsAreImportable() is a virtual function whose goal is to determin= e > if this specific table supports stats exporting. > > postgresStatisticsAreImportable() is the postgres_fdw implementation of > that virtual function. > > Any other FDWs that want to implement stats import will need to invent > their own tests and configurations to determine if that is possible. > Ok, now I understand. I thought that fetch_stats and remote_analyze was a generally fdw option and not only specific to postgres_fdw. Now I understand that is up to the fdw implementation decide how this should be enabled or disabled. Thanks for making it clear now. >> If it returns true it means that the statistics >> was imported successfully, otherwise if it returns false we could >> fallback to table sampling as we already do today. ImportStatistics >> could return false if the foreign server don't have statistics for the >> requested table, even after running ANALYZE if remote_analyze is true. >> >> Is that make sense? Any thoughts? >> > > That sounds very similar to the design that was presented in v1. > Yeah, I think that my suggestion don't make sense, I miss understood the feature. Sorry about the noise, I'll continue reviewing the v8 patch. -- Matheus Alcantara EDB: https://www.enterprisedb.com