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 1hRd1S-0000Rm-Ag for pgsql-performance@arkaria.postgresql.org; Fri, 17 May 2019 13:35:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hRd1Q-0007Er-Us for pgsql-performance@arkaria.postgresql.org; Fri, 17 May 2019 13:35:40 +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 1hRd1Q-0007EI-IU for pgsql-performance@lists.postgresql.org; Fri, 17 May 2019 13:35:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRd1O-0005dp-7f for pgsql-performance@postgresql.org; Fri, 17 May 2019 13:35:39 +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 x4HDZZaD006606; Fri, 17 May 2019 09:35:35 -0400 From: Tom Lane To: Jeremy Altavilla cc: pgsql-performance@postgresql.org Subject: Re: Analyze results in more expensive query plan In-reply-to: References: Comments: In-reply-to Jeremy Altavilla message dated "Thu, 16 May 2019 16:03:18 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6604.1558100135.1@sss.pgh.pa.us> Date: Fri, 17 May 2019 09:35:35 -0400 Message-ID: <6605.1558100135@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jeremy Altavilla writes: > We have several select statements whose performance is greatly improved by > deleting some stats from pg_statistic. You might have better results by setting up some "extended stats" for the combination of bag_type columns that this query depends on. Per your description, there's a fair amount of cross-column correlation, which the planner will not expect without some extended stats to tell it so. https://www.postgresql.org/docs/10/planner-stats.html#PLANNER-STATS-EXTENDED regards, tom lane