Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHs4V-00026k-Nu for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Dec 2016 12:57:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cHs4V-0003UG-7y for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Dec 2016 12:57:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cHs4T-0003TP-FC for pgsql-hackers@postgresql.org; Fri, 16 Dec 2016 12:57:09 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHs4L-0001td-91 for pgsql-hackers@postgresql.org; Fri, 16 Dec 2016 12:57:08 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id uBGCuu77012463; Fri, 16 Dec 2016 21:56:56 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 63E215F611; Fri, 16 Dec 2016 21:56:56 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 5524D5F592; Fri, 16 Dec 2016 21:56:56 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTP id 4AEC440034E; Fri, 16 Dec 2016 21:56:56 +0900 (JST) Subject: Re: postgres_fdw bug in 9.6 References: <6319.1481219450@sss.pgh.pa.us> <7784.1481221687@sss.pgh.pa.us> <13242.1481582736@sss.pgh.pa.us> <31740.1481819950@sss.pgh.pa.us> From: Etsuro Fujita Message-ID: Date: Fri, 16 Dec 2016 21:50:45 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit To: Tom Lane Cc: Ashutosh Bapat , Jeff Janes , Robert Haas , pgsql-hackers X-TM-AS-MML: disable X-Pg-Spam-Score: -5.7 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2016/12/16 11:25, Etsuro Fujita wrote: > As I said upthread, an alternative I am thinking is (1) to create an > equivalent nestloop join path using inner/outer paths of a foreign join > path, except when that join path implements a full join, in which case a > merge/hash join path is used, (2) store it in fdw_outerpath as-is, and > (3) during an EPQ recheck, apply postgresRecheckForeignScan to the outer > subplan created from the fdw_outerpath as-is. What do you think about > that? Let me explain about #1 and #2 a bit more. What I have in mind is: * modify postgresGetForeignPaths so that a simple foreign table scan path is stored into the base relation's PgFdwRelationInfo. * modify postgresGetForeignJoinPaths so that (a) a local join path for a 2-way foreign join is created using simple foreign table scan paths stored in the base relations' PgFdwRelationInfos, and stored into the join relation's PgFdwRelationInfo. (b) a local join path for a 3-way foreign join, whose left input is a 2-way foreign join, is created using a local join path stored in the left input join relation's PgFdwRelationInfo and a simple foreign table scan path stored into the right input base relation's PgFdwRelationInfo. (c) Likewise for higher level foreign joins. (d) local join paths created are passed to create_foreignscan_path and stored into the fdw_outerpaths of the resulting ForeignPahts. I think that that would need special handling for foreign joins with sort orders; add an explicit sort to the local join paths, if needed. I am thinking to provide a helper function that creates a local join path for (a), (b), and (c). Best regards, Etsuro Fujita -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers