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 1tiAmH-00CMMo-H9 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Feb 2025 11:19:37 +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 1tiAmE-008tTY-LO for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Feb 2025 11:19:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiAmE-008tTO-Cx for pgsql-bugs@lists.postgresql.org; Wed, 12 Feb 2025 11:19:35 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiAmC-000OvA-0d for pgsql-bugs@lists.postgresql.org; Wed, 12 Feb 2025 11:19:34 +0000 Received: from [192.168.11.2] (p1695135-ipoe.ipoe.ocn.ne.jp [118.0.92.134]) by oss.nttdata.com (Postfix) with ESMTPSA id B871D61A55; Wed, 12 Feb 2025 20:19:27 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: Date: Wed, 12 Feb 2025 20:19:27 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: reltuples decreasing with each autovacuum run To: =?UTF-8?B?5r+x5LitIOW8mOWSjA==?= , "David G. Johnston" Cc: "pgsql-bugs@lists.postgresql.org" References: Content-Language: en-US From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025/02/10 18:47, 濱中 弘和 wrote: > Dear David J., > > Thank you very much for your kind words. > > I have created a new bug report. I’ve updated the email subject to an English version for broader understanding. > ④ The skipped autovacuum was triggered every 30 seconds. Each time it triggered, pg_class.reltuples decreased. >   After about 20 triggers, pg_class.reltuples became approximately 500. As mentioned in the original thread [1], I believe this issue comes from the logic in vac_estimate_reltuples(). This function estimates reltuples by summing the number of live tuples found in scanned pages with an estimate for unscanned pages. While this seems to work well when live tuples are evenly distributed, it can underestimate reltuples if unscanned pages have a higher density of live tuples than scanned ones. Commit 74388a1ac3 seems attempt to address this by keeping the old reltuples if VACUUM scans <=2% of total pages. However, when VACUUM scans more than 2%, the estimation may still be inaccurate, leading to a gradual decrease in reltuples. One idea for this issue is to raise the threshold from 2% to, say, 10%, though this would only be a partial improvement... Alternatively, if VACUUM is likely to set incorrect reltuples, another just idea is to introduce a storage parameter to prevent VACUUM from updating it, allowing only ANALYZE to make changes. Regards, [1] https://postgr.es/m/3dec196d-72a6-447f-ad2e-f2668f2907a9@oss.nttdata.com -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION