Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8olw-0000Wm-44 for pgsql-performance@arkaria.postgresql.org; Thu, 11 May 2017 14:08:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d8olv-0007Hi-CB for pgsql-performance@arkaria.postgresql.org; Thu, 11 May 2017 14:08:51 +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_2) (envelope-from ) id 1d8okA-0002wp-MZ for pgsql-performance@postgresql.org; Thu, 11 May 2017 14:07:02 +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_2) (envelope-from ) id 1d8ok7-0001Cz-Tb for pgsql-performance@postgresql.org; Thu, 11 May 2017 14:07:01 +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 v4BE6w85008394; Thu, 11 May 2017 10:06:58 -0400 From: Tom Lane To: plukovic cc: pgsql-performance@postgresql.org Subject: Re: Speed differences between in executing the same query In-reply-to: <1494510842628-5960964.post@n3.nabble.com> References: <1494510842628-5960964.post@n3.nabble.com> Comments: In-reply-to plukovic message dated "Thu, 11 May 2017 06:54:02 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8392.1494511618.1@sss.pgh.pa.us> Date: Thu, 11 May 2017 10:06:58 -0400 Message-ID: <8393.1494511618@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 plukovic writes: > I have a weird case of query execution performance here. My first thought is that you are getting a bad plan because of this estimation error: > -> Index Scan using uk_TBL_sk0_account_code on TBL_sk > sk2_ (cost=0.14..12.53 rows=1 width=426) (actual time=1.036..1.084 rows=50 > loops=1) > Index Cond: (acco_id = 1) That rowcount estimate is off by 50X, resulting in 50X errors for the joins above it too, and in misguided choices of nestloops when some other join method would be better. Probably things would improve with a better estimate. Maybe you need to increase the stats target for that table ... or maybe it just hasn't been ANALYZEd lately? 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