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 1gx61w-0006vT-Cv for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Feb 2019 08:18:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gx61v-00052X-6e for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Feb 2019 08:17:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gx61u-00052O-ST for pgsql-hackers@lists.postgresql.org; Fri, 22 Feb 2019 08:17:59 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gx61s-0005Aw-8h for pgsql-hackers@postgresql.org; Fri, 22 Feb 2019 08:17:57 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x1M8Hs7r006755; Fri, 22 Feb 2019 17:17:54 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 393A0EA80C1; Fri, 22 Feb 2019 17:17:54 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 2E9B0EA800F; Fri, 22 Feb 2019 17:17:54 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 283E6400582; Fri, 22 Feb 2019 17:17:54 +0900 (JST) Message-ID: <5C6FB014.9040403@lab.ntt.co.jp> Date: Fri, 22 Feb 2019 17:17:24 +0900 From: Etsuro Fujita User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 Subject: Re: Problems with plan estimates in postgres_fdw References: <87pnz1aby9.fsf@news-spur.riddles.org.uk> <1175.1533220908@sss.pgh.pa.us> <5BB739CD.6040002@lab.ntt.co.jp> <5BBC4140.50403@lab.ntt.co.jp> <5C17A00E.5000005@lab.ntt.co.jp> <5C232F39.9060509@lab.ntt.co.jp> <5C25C7B5.2010802@lab.ntt.co.jp> <5C518631.5080401@lab.ntt.co.jp> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Jeff Janes Cc: Tom Lane , Andrew Gierth , pgsql-hackers X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Jeff, (2019/02/21 6:19), Jeff Janes wrote: > On Wed, Jan 30, 2019 at 6:12 AM Etsuro Fujita > > wrote: > > (2018/12/28 15:50), Etsuro Fujita wrote: > > Attached is a new version of the > > patch. > > Here is an updated version of the patch set. Changes are: > > * In the previous version, LIMIT without OFFSET was not performed > remotely as the costs was calculated the same as the costs of > performing > it locally. (Actually, such LIMIT was performed remotely in a case in > the postgres_fdw regression test, but that was due to a bug :(.) I > think we should prefer performing such LIMIT remotely as that avoids > extra row fetches from the remote that performing it locally might > cause, so I tweaked the costs estimated in > estimate_path_cost_size(), to > ensure that we'll prefer performing such LIMIT remotely. > With your tweaks, I'm still not seeing the ORDER-less LIMIT get pushed > down when using use_remote_estimate in a simple test case, either with > this set of patches, nor in the V4 set. However, without > use_remote_estimate, the LIMIT is now getting pushed with these patches > when it does not in HEAD. Good catch! I think the root cause of that is: when using use_remote_estimate, remote estimates obtained through remote EXPLAIN are rounded off to two decimal places, which I completely overlooked. Will fix. I think I can post a new version early next week. > See attached test case, to be run in new database named 'foo'. Thanks for the review and the test case! Best regards, Etsuro Fujita