Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIaJ8-00053P-Mj for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 18:06:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIaJ7-0001tq-J2 for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 18:06:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIaJ7-0001tg-9p for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 18:06:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIaJ2-0007tO-6v for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 18:06:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 21BI61Gl2082310; Fri, 11 Feb 2022 13:06:01 -0500 From: Tom Lane To: Robert Haas cc: Tomas Vondra , PostgreSQL Hackers Subject: Re: postgres_fdw: using TABLESAMPLE to collect remote sample In-reply-to: References: <151e835f-55d6-ddbc-b5b4-07ee606aba44@enterprisedb.com> <2080021.1644601183@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 11 Feb 2022 12:43:31 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2082307.1644602761.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 11 Feb 2022 13:06:01 -0500 Message-ID: <2082308.1644602761@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > I think it's going to be necessary to compromise on that at some > point. Sure. The existing postgres_fdw documentation [1] already addresses this issue: postgres_fdw can be used with remote servers dating back to PostgreSQL 8.3. Read-only capability is available back to 8.1. A limitation however is that postgres_fdw generally assumes that immutable built-in functions and operators are safe to send to the remote server for execution, if they appear in a WHERE clause for a foreign table. Thus, a built-in function that was added since the remote server's release might be sent to it for execution, resulting in “function does not exist” or a similar error. This type of failure can be worked around by rewriting the query, for example by embedding the foreign table reference in a sub-SELECT with OFFSET 0 as an optimization fence, and placing the problematic function or operator outside the sub-SELECT. While I'm not opposed to moving those goalposts at some point, I think pushing them all the way up to 9.5 for this one easily-fixed problem is not very reasonable. Given other recent discussion, an argument could be made for moving the cutoff to 9.2, on the grounds that it's too hard to test against anything older. But that still leaves us needing a version check if we want to use TABLESAMPLE. regards, tom lane [1] https://www.postgresql.org/docs/devel/postgres-fdw.html#id-1.11.7.45.17