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.96) (envelope-from ) id 1wAbLE-0007ad-1f for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 22:25:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAbLC-002RX3-18 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 22:25:43 +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.96) (envelope-from ) id 1wAbLB-002RWt-2A for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 22:25:42 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAbLA-0000000042j-1bli for pgsql-hackers@postgresql.org; Wed, 08 Apr 2026 22:25:41 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 6BECEEC0400; Wed, 8 Apr 2026 18:23:55 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Wed, 08 Apr 2026 18:23:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1775687035; x=1775773435; bh=OSth7/BKvuHJQj5zqVFUF1MnuK5m0cVY7BcEfzmjWj8=; b= cDVLQQJYeXMAPo7pDmB0diR/85ulxoXJYTpjCxd0W7ZtDbY0QSRVBTO9HRbT60u5 WWL9c91KMazsymPpqikLDb0Sbj46FX0y6jHDdi7jN67pdDvZepWykaQns31MbqJB TMAoX6M4MpdehDXI9X7mtUCSNTYB+0SCcqgSKV2MMgW/8JJUElgqmPHCkClIMp/H Csa2MFfPI/0XazLzxR40YmlgV1PuP8zBsxOy/Kku9yOnckZUfb7G7KrJdMUphSZ/ QOMOUQaItMXBe6LcRC9XdgOIwxfb2FY8ZxxRoTMqioHCtrqdQUe0NT2XzsjzhjYL /G/BEJekDSqiviiPI4SLcg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1775687035; x= 1775773435; bh=OSth7/BKvuHJQj5zqVFUF1MnuK5m0cVY7BcEfzmjWj8=; b=X 6y+iR6yV3klSGKFxTs6Ui5Fx4PdO6D7z8Z6H/Jgftc4URmSD1QNaEtsf3yxtXCl3 AgCMa9jfXcdrByxQeq/FiKlx/zK7h3PYI6/44QWuurx7Y4NhCZu1WBZljDl4NeiS Z93cHx5CParCDMsyVrCDu1hp6Sq2n5Cm+b5oZhnd7G07iRaKU8NIungB0H7iGgfC x3HFmrLTFJ6O/gNKN8V6lC2bRhBLFC8yMa8Zi/UTFW+zJ2RGNH7fY0YDHr2YL+wQ 9pGXEGXEAZ1YimlJFWURj6wA3RT7P8KBQ0uXb3jkE4nrBfmTlTyXiIlLfMrf3ZXY hqRoZgBXiYkqcXmM/f4Tw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddvgeejiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtugfgjgestheksfdttddtjeenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnheptdelledvgfejvdffieeukeefueelfffhgeffhffgffekveeuheeihefhiefg hfdvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeelpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegshhgrrhgrthhhrdhruhhpihhrvgguugihfhhorh hpohhsthhgrhgvshesghhmrghilhdrtghomhdprhgtphhtthhopegvgigtlhhushhiohhn sehgmhgrihhlrdgtohhmpdhrtghpthhtohepnhgrthhhrghnuggsohhsshgrrhhtsehgmh grihhlrdgtohhmpdhrtghpthhtohepshgrmhhimhhsvghihhesghhmrghilhdrtghomhdp rhgtphhtthhopehsrghthigrnhgrrhhlrghpuhhrrghmsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepthhnughrfigrnhhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhq lhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepthhglh esshhsshdrphhghhdrphgrrdhushdprhgtphhtthhopehrohgsseigiihilhhlrgdrnhgv th X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Apr 2026 18:23:54 -0400 (EDT) Date: Wed, 8 Apr 2026 18:23:54 -0400 From: Andres Freund To: Nathan Bossart Cc: Tom Lane , Alexander Lakhin , Sami Imseih , Bharath Rupireddy , Robert Treat , satyanarlapuram@gmail.com, pgsql-hackers , tndrwang@gmail.com Subject: Re: Add pg_stat_autovacuum_priority Message-ID: References: <5684f479-858e-4c5d-b8f5-bcf05de1f909@gmail.com> <3077290.1775668665@sss.pgh.pa.us> <3097984.1775674400@sss.pgh.pa.us> <3101163.1775676098@sss.pgh.pa.us> <3nob5fjwrar3shffl5yo7im4qlnxxa475pi6fohemodsvwpl5g@l5cbmz5dqtjm> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3nob5fjwrar3shffl5yo7im4qlnxxa475pi6fohemodsvwpl5g@l5cbmz5dqtjm> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-08 17:59:36 -0400, Andres Freund wrote: > I don't think it should be quite 16MB for 100k tables though? I see > > ┌────────────────────────┬────────────────┐ > │ name │ pg_size_pretty │ > ├────────────────────────┼────────────────┤ > │ PgStat Shared Ref │ 8104 kB │ > │ PgStat Shared Ref Hash │ 4097 kB │ > │ CacheMemoryContext │ 1024 kB │ > └────────────────────────┴────────────────┘ > after doing > > SELECT sum(score) FROM pg_stat_autovacuum_scores; > > in this database: > > SELECT relkind, count(*) FROM pg_class GROUP BY relkind; > ┌─────────┬────────┐ > │ relkind │ count │ > ├─────────┼────────┤ > │ S │ 1 │ > │ i │ 182 │ > │ r │ 102292 │ > │ t │ 43 │ > │ v │ 167 │ > └─────────┴────────┘ > (5 rows) (8104 * 1024) / 102292 = 81.13 81 bytes eemed a bit high, given the struct is 48 bytes. My first thought is that this was from a debug build, where allocations have more overhead. And indeed, in an optimized build it's "just" 7248kB, a per-entry size of 78.78. A lot of that is probably due to rounding up in aset.c (and perhaps a bit due to ALLOCSET_SMALL_SIZES). Since "PgStat Shared Ref" only ever does one type of allocation, it actually is a good candidate for slab. In debug that's 7248kB and optimized it's 5632kB, when using a 16kB block size. The latter is 56 bytes per entry, where sizeof(PgStat_EntryRef) is 48 bytes. Which is a pretty reasonable allocator overhead and 16kB seems not too crazy an allocator block size for this? Note that even if you just \dt in that database, you have a CacheMemoryContext of 41MB. If you VACUUM the caches are 121MB. Greetings, Andres Freund