Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1reHZg-00AVZn-KQ for pgsql-admin@arkaria.postgresql.org; Sun, 25 Feb 2024 16:42:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1reHZe-00800w-Ka for pgsql-admin@arkaria.postgresql.org; Sun, 25 Feb 2024 16:41:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1reHZe-00800o-9n for pgsql-admin@lists.postgresql.org; Sun, 25 Feb 2024 16:41:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1reHZc-000tyN-QR for pgsql-admin@lists.postgresql.org; Sun, 25 Feb 2024 16:41:58 +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 41PGfsL21503698; Sun, 25 Feb 2024 11:41:54 -0500 From: Tom Lane To: Sai Sadashiva Kundurmutt cc: pgsql-admin@lists.postgresql.org Subject: Re: Are the estimates made for number of pages accurate In-reply-to: References: Comments: In-reply-to Sai Sadashiva Kundurmutt message dated "Sun, 25 Feb 2024 14:10:05 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1503696.1708879314.1@sss.pgh.pa.us> Date: Sun, 25 Feb 2024 11:41:54 -0500 Message-ID: <1503697.1708879314@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sai Sadashiva Kundurmutt writes: > I wanted to know whether the numbers calculated by ANALYZE for number of > pages are exact(the relpages field in pg_class). If memory serves, relpages is accurate as of the time of the last VACUUM or ANALYZE on the table, but of course it could be arbitrarily out of date later. > I had the impression that > it is exact because during random sampling the number of pages is assumed > to be known. What makes you think that? And even more to the point, what makes you think that we'd rely on relpages for such a purpose? I'd expect a fresh RelationGetNumberOfBlocks call in any scan that had a need to know the table size. regards, tom lane