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 1k47JP-0008SB-96 for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Aug 2020 18:41:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k47JN-000615-IA for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Aug 2020 18:41:49 +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 1k47JN-00060y-BI for pgsql-hackers@lists.postgresql.org; Fri, 07 Aug 2020 18:41:49 +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 1k47JK-0000ZW-K8 for pgsql-hackers@lists.postgresql.org; Fri, 07 Aug 2020 18:41:48 +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 077IffS42793036; Fri, 7 Aug 2020 14:41:41 -0400 From: Tom Lane To: Robert Haas cc: Andres Freund , Alvaro Herrera , James Coleman , pgsql-hackers , Simon Riggs Subject: Re: PROC_IN_ANALYZE stillborn 13 years ago In-reply-to: References: <20200805021435.GA9523@alvherre.pgsql> <20200805235549.GA8118@alvherre.pgsql> <20200806010711.mzvu36zy25xer33t@alap3.anarazel.de> <2637311.1596739058@sss.pgh.pa.us> <2638833.1596741087@sss.pgh.pa.us> <2647180.1596749733@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 07 Aug 2020 14:03:37 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2793034.1596825701.1@sss.pgh.pa.us> Date: Fri, 07 Aug 2020 14:41:41 -0400 Message-ID: <2793035.1596825701@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > Thinking about it more, there are really two ways to think about an > estimated row count. > On the one hand, if you think of the row count estimate as the number > of rows that are going to pop out of a node, then it's always right to > think of a unique index as limiting the number of occurrences of a > given value to 1. But, if you think of the row count estimate as a way > of estimating the amount of work that the node has to do to produce > that output, then it isn't. The planner intends its row counts to be interpreted in the first way. We do have a rather indirect way of accounting for the cost of scanning dead tuples and such, which is that we scale scanning costs according to the measured physical size of the relation. That works better for I/O costs than it does for CPU costs, but it's not completely useless for the latter. In any case, we'd certainly not want to increase the scan's row count estimate for that, because that would falsely inflate our estimate of how much work upper plan levels have to do. Whatever happens at the scan level, the upper levels aren't going to see those dead tuples. regards, tom lane