Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8ROa-0007uw-Mn for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Apr 2018 14:15:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f8ROZ-0001xD-ND for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Apr 2018 14:15:43 +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.89) (envelope-from ) id 1f8ROZ-0001x4-E0 for pgsql-bugs@lists.postgresql.org; Tue, 17 Apr 2018 14:15:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8ROW-0002fv-PP for pgsql-bugs@lists.postgresql.org; Tue, 17 Apr 2018 14:15:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w3HEFcJj015036; Tue, 17 Apr 2018 10:15:38 -0400 From: Tom Lane To: alexey.ermakov@dataegret.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15160: planner overestimates number of rows in join when there are more than 200 rows coming from CTE In-reply-to: <152395805004.19366.3107109716821067806@wrigleys.postgresql.org> References: <152395805004.19366.3107109716821067806@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Tue, 17 Apr 2018 09:40:50 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15034.1523974538.1@sss.pgh.pa.us> Date: Tue, 17 Apr 2018 10:15:38 -0400 Message-ID: <15035.1523974538@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > I'm wondering how planner estimates number of rows in that case: See eqjoinsel_semi, particularly the change in behavior when it thinks nd2 is or is not a default estimate. Given the lack of statistics about the output of the WITH clause, it's hard to see how we'd ever get trustworthy estimates here. I think the fact that your first example yields an accurate estimate is mostly luck. regards, tom lane