Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zrrta-0000ce-RL for pgsql-performance@arkaria.postgresql.org; Thu, 29 Oct 2015 18:25:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zrrta-0007qN-7W for pgsql-performance@arkaria.postgresql.org; Thu, 29 Oct 2015 18:25:54 +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) (envelope-from ) id 1Zrrrv-0005Oo-Gt for pgsql-performance@postgresql.org; Thu, 29 Oct 2015 18:24:11 +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.84) (envelope-from ) id 1Zrrrs-00025I-Nj for pgsql-performance@postgresql.org; Thu, 29 Oct 2015 18:24:10 +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 t9TIO7aR002142; Thu, 29 Oct 2015 14:24:07 -0400 From: Tom Lane To: Matthew Bellew cc: pgsql-performance@postgresql.org Subject: Re: Query optimizer plans with very small selectivity estimates In-reply-to: References: Comments: In-reply-to Matthew Bellew message dated "Thu, 29 Oct 2015 09:52:13 -0700" Date: Thu, 29 Oct 2015 14:24:07 -0400 Message-ID: <2141.1446143047@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Matthew Bellew writes: > I made have several users encounter performance problems, which all > seem to come down to this problem: multiplying selectivity estimates can > cause tuple estimates to grow very small very quickly, once the estimator > gets to 1 row, the planner may choose plans that are very good ONLY WHEN > there is exactly 1 row (maybe even O(N^large)). Unfortunately, these may > be the worst plans if the estimate is even slightly off (even just > returning 2 or 3 rows versus 1). Yeah, this is a well-known problem. There has been prior discussion along the same lines as you mention (only believe 1-row estimates when it's provably true that there's at most one row), but it hasn't looked like an easy change. See the pgsql-hackers archives for previous threads. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance