Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zrx8r-0005VQ-Gz for pgsql-performance@arkaria.postgresql.org; Fri, 30 Oct 2015 00:02:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zrx8p-00040l-TD for pgsql-performance@arkaria.postgresql.org; Fri, 30 Oct 2015 00:01:59 +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 1Zrx7C-0002A2-AO for pgsql-performance@postgresql.org; Fri, 30 Oct 2015 00:00:18 +0000 Received: from mx-out.zmailcloud.com ([192.198.85.98] helo=mx-out-1.zmailcloud.com) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Zrx78-0000QN-S5 for pgsql-performance@postgresql.org; Fri, 30 Oct 2015 00:00:17 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 31ACB563F9C; Thu, 29 Oct 2015 19:00:13 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 2020A601AB; Thu, 29 Oct 2015 19:00:13 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K_tAqZi4mu7C; Thu, 29 Oct 2015 19:00:13 -0500 (CDT) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id F10BB601D4; Thu, 29 Oct 2015 19:00:12 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id D33FC601AB; Thu, 29 Oct 2015 19:00:12 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lqu4BbQVFu5o; Thu, 29 Oct 2015 19:00:12 -0500 (CDT) Received: from [172.47.23.105] (50-0-190-244.dsl.dynamic.fusionbroadband.com [50.0.190.244]) by smtp-out-2.01.com (Postfix) with ESMTPSA id 1977E6023E; Thu, 29 Oct 2015 19:00:11 -0500 (CDT) Subject: Re: Query optimizer plans with very small selectivity estimates To: Tom Lane , Matthew Bellew References: <2141.1446143047@sss.pgh.pa.us> Cc: pgsql-performance@postgresql.org From: Josh Berkus Organization: PostgreSQL Experts Inc. Message-ID: <5632B307.2000905@agliodbs.com> Date: Thu, 29 Oct 2015 17:00:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 On 10/29/2015 11:24 AM, Tom Lane wrote: > 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. Also see Tomas's correlated stats patch submitted for 9.6. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance