Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1HLo-00038u-EK for pgsql-performance@arkaria.postgresql.org; Sun, 08 Oct 2017 19:35:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e1HLn-0000d7-NF for pgsql-performance@arkaria.postgresql.org; Sun, 08 Oct 2017 19:34:59 +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.84_2) (envelope-from ) id 1e1HLn-0000cx-6q for pgsql-performance@postgresql.org; Sun, 08 Oct 2017 19:34:59 +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.84_2) (envelope-from ) id 1e1HLj-0000m5-7q for pgsql-performance@postgresql.org; Sun, 08 Oct 2017 19:34:58 +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 v98JYpIJ011435; Sun, 8 Oct 2017 15:34:52 -0400 From: Tom Lane To: Jim Nasby cc: "pgsql-performance@postgresql.org" Subject: Re: Regression from 9.4-9.6 In-reply-to: <5d7c0f80-3767-1531-d911-197fcc147173@nasby.net> References: <5d7c0f80-3767-1531-d911-197fcc147173@nasby.net> Comments: In-reply-to Jim Nasby message dated "Sun, 08 Oct 2017 14:25:54 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11433.1507491291.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 08 Oct 2017 15:34:51 -0400 Message-ID: <11434.1507491291@sss.pgh.pa.us> 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 Jim Nasby writes: > I've got a query that's regressed from 9.4 to 9.6. I suspect it has=20 > something to do with the work done around bad plans from single-row=20 > estimates. Why has this indexscan's cost estimate changed so much? >> -> Index Scan using bdata_filed_departuretime on bdata_forks (cost=3D0= .57..50807.51 rows=3D1 width=3D36) (actual time=3D979.381..3207.777 rows=3D= 508 loops=3D1) >> -> Index Scan using bdata_filed_departuretime on bdata_forks (cost=3D0= .57..14894236.06 rows=3D1 width=3D36) (actual time=3D892.664..3025.653 rows= =3D508 loops=3D1) I think the reason it's discarding the preferable plan is that, with this huge increment in the estimated cost getting added to both alternatives, the two nestloop plans have fuzzily the same total cost, and it's picking the one you don't want on the basis of some secondary criterion. regards, tom lane --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance