Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lFTMg-0007Fd-4a for pgsql-performance@arkaria.postgresql.org; Fri, 26 Feb 2021 03:00:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lFTMf-0003l2-3b for pgsql-performance@arkaria.postgresql.org; Fri, 26 Feb 2021 03:00:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lFTMe-0003kv-Sz for pgsql-performance@lists.postgresql.org; Fri, 26 Feb 2021 03:00:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lFTMc-0007aw-SW for pgsql-performance@postgresql.org; Fri, 26 Feb 2021 03:00:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 11Q30IDE219913; Thu, 25 Feb 2021 22:00:18 -0500 From: Tom Lane To: Arne Roland cc: "pgsql-performance@postgresql.org" Subject: Re: Disabling options lowers the estimated cost of a query In-reply-to: <1581042da8044e71ada2d6e3a51bf7bb@index.de> References: <1581042da8044e71ada2d6e3a51bf7bb@index.de> Comments: In-reply-to Arne Roland message dated "Thu, 25 Feb 2021 23:07:08 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <219911.1614308418.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 25 Feb 2021 22:00:18 -0500 Message-ID: <219912.1614308418@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Arne Roland writes: > I want to examine the exhaustive search and not the geqo here. I'd expec= t the exhaustive search to give the plan with the lowest cost, but apparen= tly it doesn't. I have found a few dozen different querys where that isn't= the case. I attached one straight forward example. For the join of two pa= rtitions a row first approach would have been reasonable. Hmm. While the search should be exhaustive, there are pretty aggressive pruning heuristics (mostly in and around add_path()) that can cause us to drop paths that don't seem to be enough better than other alternatives. I suspect that the seqscan plan may have beaten out the other one at some earlier stage that didn't think that the startup-cost advantage was sufficient reason to keep it. It's also possible that you've found a bug. I notice that both plans are using incremental sort, which has been, um, rather buggy. Hard to tell without a concrete test case to poke at. regards, tom lane