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 1wAYTF-0005MX-03 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 19:21:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAYTD-001eLu-0L for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 19:21:48 +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.96) (envelope-from ) id 1wAYTC-001eLa-2e for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 19:21:47 +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.98.2) (envelope-from ) id 1wAYT6-000000003SC-35Gk for pgsql-hackers@postgresql.org; Wed, 08 Apr 2026 19:21:42 +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 638JLcjn3101164; Wed, 8 Apr 2026 15:21:38 -0400 From: Tom Lane To: Nathan Bossart cc: Alexander Lakhin , Sami Imseih , Bharath Rupireddy , Robert Treat , satyanarlapuram@gmail.com, pgsql-hackers , tndrwang@gmail.com Subject: Re: Add pg_stat_autovacuum_priority In-reply-to: References: <5684f479-858e-4c5d-b8f5-bcf05de1f909@gmail.com> <3077290.1775668665@sss.pgh.pa.us> <3097984.1775674400@sss.pgh.pa.us> Comments: In-reply-to Nathan Bossart message dated "Wed, 08 Apr 2026 14:09:48 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3101162.1775676098.1@sss.pgh.pa.us> Date: Wed, 08 Apr 2026 15:21:38 -0400 Message-ID: <3101163.1775676098@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Wed, Apr 08, 2026 at 02:53:20PM -0400, Tom Lane wrote: >> ... Aside from this problem, the elog's that >> relation_needs_vacanalyze emits seem 100% inappropriate and misleading >> when it's being called from the view. > FWIW that elog() shouldn't be emitting anything from the view, unless > something is broken. [ looks again... ] Oh, you mean because pg_stat_get_autovacuum_scores passes 0 for elevel instead of any of the valid elevel constants. Can you say "undocumented cowboy hack"? I'd be happier if we added something like "#define LOG_NEVER 0 /* Never emit this message */" to elog.h and used that. >> 2. Add a "bool *should_free" parameter, like we have in tuplestores >> and some other places. It's on the caller to pfree if should_free >> gets set, but since we'd have to touch every caller, we'd not miss >> any. > This sounds most similar to the "bool *may_free" idea that Andres just > posted. IIUC the idea is that callers can free the result if they want, > but they aren't required to do so. Hmm, yeah I suppose a caller that doesn't care about leakage could skip the pfree. But are there really any of those? The complaint that prompted 02502c1bc concerned databases with many many thousands of relations. I now realize that what you said upthread about caching the results might be a bigger problem, ie if the pgstats code does retain all these values then we'd have a memory bloat problem there. Maybe we need a more aggressive API change that includes a way to specify "don't cache this result". regards, tom lane