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 1exxXy-0007mS-Lo for pgsql-performance@arkaria.postgresql.org; Mon, 19 Mar 2018 16:22:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1exxXx-0001Ur-3A for pgsql-performance@arkaria.postgresql.org; Mon, 19 Mar 2018 16:22:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exxXw-0001Uh-Rg for pgsql-performance@lists.postgresql.org; Mon, 19 Mar 2018 16:22:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exxXu-0001h0-4S for pgsql-performance@postgresql.org; Mon, 19 Mar 2018 16:22:04 +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 w2JGM0hg001566; Mon, 19 Mar 2018 12:22:00 -0400 From: Tom Lane To: David Osborne cc: pgsql-performance@postgresql.org Subject: Re: Slow performance after restoring a dump In-reply-to: References: <31890.1521473700@sss.pgh.pa.us> Comments: In-reply-to David Osborne message dated "Mon, 19 Mar 2018 15:43:47 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1564.1521476520.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 19 Mar 2018 12:22:00 -0400 Message-ID: <1565.1521476520@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Osborne writes: > Hi, yes I've run "analyse" against the newly restored database. Should t= hat > be enough? My apologies, you did say that further down in the original message. It looks like the core of the problem is the poor rowcount estimation here: -> Bitmap Index Scan on stock_trans_product_idx (cos= t=3D0.00..31.42 rows=3D1465 width=3D0) (actual time=3D0.009..0.009 rows=3D= 0 loops=3D1) Index Cond: (product_id =3D 2466420) Buffers: shared hit=3D3 You might be able to improve that by raising the statistics target for stock_trans.product_id. I'm not sure why you weren't getting bitten by the same issue in 9.1; but the cost estimates aren't that far apart for the two plans, so maybe you were just lucky ... regards, tom lane