Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipbIv-0003gQ-9J for pgsql-general@arkaria.postgresql.org; Thu, 09 Jan 2020 17:09:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipbIu-0003mv-2K for pgsql-general@arkaria.postgresql.org; Thu, 09 Jan 2020 17:09:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipbIt-0003mm-P9 for pgsql-general@lists.postgresql.org; Thu, 09 Jan 2020 17:09:03 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ipbIq-0003m7-J2 for pgsql-general@lists.postgresql.org; Thu, 09 Jan 2020 17:09:03 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id ADB4C5F799; Thu, 9 Jan 2020 12:09:00 -0500 (EST) Date: Thu, 9 Jan 2020 12:09:00 -0500 From: Stephen Frost To: Tom Lane Cc: shigeo Hirose , pgsql-general@lists.postgresql.org Subject: Re: How can I pushdown of functions used in targetlist with FDW ? Message-ID: <20200109170900.GU3195@tamriel.snowman.net> References: <19345.1578545599@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SmT8F4qlEF5oRUsX" Content-Disposition: inline In-Reply-To: <19345.1578545599@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --SmT8F4qlEF5oRUsX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Tom Lane (tgl@sss.pgh.pa.us) wrote: > shigeo Hirose writes: > > How can I pushdown of functions used in targetlist with FDW ? >=20 > There is, AFAIK, no provision for that. There's not a lot of > reason to consider adding it either, because there's no reason > to suppose that the remote node can run such a function any > faster than the local node. So the difficulty and risk of > determining/assuming that f(x) on the local node is the same > as f(x) on the remote node doesn't seem like it'd be repaid. Well, for starters, isn't there something in the SQL/MED spec about this..? Next, we already do this for aggregates. Also, I don't think I agree with this particular position- it's entirely possible that the remote server is much less loaded/busy than the local one and therefore it'd be beneficial, overall, to run that function on the remote system and not the local one. The function might even have side-effects or use other objects in the system to run. The function may also return a much smaller result than pulling back the raw data (of course, the opposite could also possibly be true). I guess my gut feeling is that, in general, we should push down as much of the query as possible, as we do for aggregates and joins and conditionals. I appreciate that there's some complications here when it comes to figuring out if it's possible/reasonable to push down something like, say, a volatile function that's locally defined and known to exist on the remote. Haven't got a particular idea how to address that offhand but that doesn't change my feelings that we should have a way to do this generally and that it would actually be useful to have. Thanks, Stephen --SmT8F4qlEF5oRUsX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJeF14sAAoJEO1sijiDR2RVoacP/3KIZ3OMc2mWVOpnaNiueSUq UczqfJuQEyP43KfNPIg2iYU+p1XVibBElEryHV3K0pkzDr19Ob8ojUdBoFIS5oMo mTv2yfX35eFmJzQ0x+Yvvyd6fR8X9xQgLD5jkc9QlHwknBuKh5UT8QA7m3hdBdTD kolbPVWAAcu9OwLOuthLrrUysVrELp2XwsffSox9FsAXzFQ7kE487t8ymFPI2XbG DQJTfWe+Yg4m5HYynUq4t3llsgCzTuJKnh6EnvLMiIsKq/1utm2I1UPyvT+9f2jt tULGkNkKxV1i6zanappMgOL2QyPjXAWOpfY81ZJhhuZFl0GC2PPOsZ/UOCnSdBd/ Qk4dv9/ZNJe3ucDJy6D0Qlg8yRK/KPVpudb/TUsH2yp0gdzsPcaV3SiCWMgvwvCO XNKTOgh7Bedbr/Mrw52mfmtsbO6hpE7KA5mNpIVNIXXsQWgE13hYYvK5GHlK6XNP PI4AFY6nBgJw8vmHl3jy8fyD2A9He+NJHEOT6D8DvxNB6nvMjWNUHFDCEDHeWys9 qKFinxAeHR3j75rxIuhtpWxOwzUVTZyqtTgNKfdB3PvdlYsIFfzptdr1qnsMJzMZ /kh/ePRGZjDEbHD9fehb/PycsehPjPiERyOlqeNrsuJRqCKxApw3Xc8trsSbJXUI yP/eggU7ZdJP7s7XtQ/v =wVUP -----END PGP SIGNATURE----- --SmT8F4qlEF5oRUsX--