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 1pRcmp-0003qU-A4 for pgsql-general@arkaria.postgresql.org; Mon, 13 Feb 2023 17:38:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pRcmo-0004v6-6T for pgsql-general@arkaria.postgresql.org; Mon, 13 Feb 2023 17:38:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRcmn-0004ux-S4 for pgsql-general@lists.postgresql.org; Mon, 13 Feb 2023 17:38:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRcml-00044r-Pe for pgsql-general@lists.postgresql.org; Mon, 13 Feb 2023 17:38:41 +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 31DHcCkW1265871; Mon, 13 Feb 2023 12:38:13 -0500 From: Tom Lane To: Peter cc: pgsql-general@lists.postgresql.org Subject: Re: [Testcase] Queries running forever, because of wrong rowcount estimate In-reply-to: References: Comments: In-reply-to Peter message dated "Mon, 13 Feb 2023 06:33:02 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1265869.1676309892.1@sss.pgh.pa.us> Date: Mon, 13 Feb 2023 12:38:12 -0500 Message-ID: <1265870.1676309892@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter writes: > "rows=1" in the "Hash Anti Join" line is WRONG. It should be > 3000000. Or at least some thousands. FWIW, this behaves better in v14 and up. In older versions there's an ambiguity about what relpages=reltuples=0 means; it's the state when ANALYZE has never yet examined the table contents, but it's also the state when we have found the table to be empty. Because of the former case, older planner versions don't like to believe that a table is empty even if reltuples says so. regards, tom lane