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 1w7bx5-005Wbw-0c for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 16:28:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7bx3-00BMrO-1E for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Mar 2026 16:28:25 +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 1w7bx3-00BMrG-0I for pgsql-hackers@lists.postgresql.org; Tue, 31 Mar 2026 16:28:25 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7bx0-00000002Cad-29GX for pgsql-hackers@postgresql.org; Tue, 31 Mar 2026 16:28:24 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-46703fb602fso1939425b6e.0 for ; Tue, 31 Mar 2026 09:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774974501; x=1775579301; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=uxGDGnXLXgFUuq0YXsNRyKaUXVjpsS2g3Bpxex0dM+Y=; b=kAisLNzklFzxbl+MSrj1XPCx4P+wZD0ZCcZMfO+weyRLsBjXEZ4wS0CiBwyYJS6T+Z rrHBsd8JIPzIQi3/k8LdJ+SmXVVP545laA8gd8G5KNaTdCLF9PuLeXtph7mD4ujXa1Tp PNVH/45ALl10Uu75TdR3/g/aVrZCuPRkISSGZJ+nQTX8qE1ORA0k/e2uUkPdx46QnHBJ Pe3Yiw2a1pFnhc6GI59qdbnHoQti7LEiUFT6mWSgiqMFNv4ds+D6ZJqek1cDcQhYwWzs pRo5yRHy02G3k/LSpb/PnDxq+JDyI3Nkzwv+nLrwV3u9Lmk7N6XSHxYwXA43ewGfRqnI nlpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774974501; x=1775579301; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uxGDGnXLXgFUuq0YXsNRyKaUXVjpsS2g3Bpxex0dM+Y=; b=MX4Vt92LnVxrdWxQ14wV7RLkbDOtu6NET+bbaSjAPtAM+rbtCgF9abd1r48I3mkEVN /KYJBibsUo+pW94Q0Y+qeM6gqBfAn+UOCfy1UXAqeubnCNx1jHoQSPfEhZ2jWTc1lOfY h1AdvsLEUzm/8kGprBezB2+6BQR/0MtQ+AHSYff00g9CLWkPO1G8mXe5YLF2avR9b/ho JA313zflrapmTvHPK0MM2ZWIBiOb6azlaG1vhTV/T8Drrr41UnbsKX1KFh/Hc+TWksKY EjhiIhmwC9HupNvuzw+BMIn1V+g6e+ZY8czNK2lPjw4O5t7gKdSPV71pZXhc+0G+hoJQ r/Xg== X-Forwarded-Encrypted: i=1; AJvYcCVIa/2S/LCqWcQATMiwiL3ym6Is9YmH8NCxI74hMYq2cKPkddc5BBnwEcbqO37PwMHI2ah5zz7H7voQR/Gz@postgresql.org X-Gm-Message-State: AOJu0Yx51RAfUZi2YHIvNrweSutm+nN6w85JUVd0GqEETgDh6/aVWkx2 eOgR30GaygUAdzfWQVvRV7KTXeNxMXuAE4RgN8mXVdkyc0EOANxGvxVs X-Gm-Gg: ATEYQzyTYHmmn9Q8wouaMpvKaFjd5x6bLXRlYF98WiBWlQl0ewwCVU3c75r8bIhRGmE zYubQwsWtT0RIP0UHSlQ0oCDNM4+n7ojxTVt2uDBB9gq5jdw3caq0tcQDqvjyvm4UJNn2hsMcAw dbM6QRGuRE7jfjDwo92MD0Ft1fh12jmJ+EgBzd/cfRR6GtEhbutOiPd74fnbSlVEw5XxgN7n66n C8CjTa6eMNW3m5VVfFUc5iE6REE3mD4x+z15GHhqjIErffWzqE1j/LCSbMPe+hnmoX0lmCiqqv4 XTwOIcYljGMHlNZDTIsMGPYXLyiHS2gwsHAYqnBM19QO3QyGBijI9n40P0OFSW+JZHxJnAElFDA zXuy6e8e5CYHnpo3fC2Yst/+gOQqCjujkh/w8av08LW2R06ImQQUqopIZV5RjGJ4b7oqD9XjJdm etqXT0+7eUqDcg/IY8lyUVWhHHNYOxYZ1XujDR3HshzOsnFrQbgDPD4UWIKsqvyWt69RkqEyJpz 8vKg658idX7lYmz8l97Hg== X-Received: by 2002:a05:6808:4f5e:b0:45f:318:ada0 with SMTP id 5614622812f47-46ae00be039mr11342b6e.22.1774974500686; Tue, 31 Mar 2026 09:28:20 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 5614622812f47-46a9fe96897sm7163093b6e.2.2026.03.31.09.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 09:28:19 -0700 (PDT) Date: Tue, 31 Mar 2026 11:28:18 -0500 From: Nathan Bossart To: Sami Imseih Cc: Robert Treat , Bharath Rupireddy , satyanarlapuram@gmail.com, pgsql-hackers Subject: Re: Add pg_stat_autovacuum_priority Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 31, 2026 at 11:15:35AM -0500, Sami Imseih wrote: >> + * force_scores set to true forces the computation of a score. This is useful for >> + * tools that wish to inspect scores outside of the do_vacuum() path. >> >> I'm of two minds about this new function parameter. On one hand, I see the >> utility of forcing score calculations even when autovacuum is disabled. On >> the other hand, when autovacuum is disabled, the scores are actually 0.0, >> and it's probably a good idea to report exactly what autovacuum workers >> see. > > I went back and forth on this. Showing 0.0 when autovacuum is disabled > would reflect what autovacuum workers actually see, but I think the more > useful behavior is to always compute the score based on the table's actual > state. This way, a DBA who has disabled autovacuum on a table can still > see that its score is climbing and needs attention. The view shows need, > not eligibility. This will also make the view more useful for maintenance > jobs that wish to supplement autovacuum by looking at high scores > and triggering a manual vacuum for those tables. That's a fair point. >> I also see that we're not forcing the computation of the (M)XID >> scores. Is that intentional? > > hmm, the force_score does not need to be in the force_vacuum path > because the score is calculated there naturally when the table is in > need of force_vacuum. The force_score is there to ensure that > we are not existing early in the autovacuum disabled case. So, unless the table is beyond a freeze-max-age parameter, the (M)XID scores will always be 0.0? >> I wonder if we can rework this function to always calculate the scores, >> even if autovacuum is disabled or !force_vacuum. This way, both paths are >> doing the exact same thing and reporting the same scores. > > I prefer that we still calculate the score as if autovacuum is enabled > for the reason above. I do think one potential middle ground is to have > needs_analyze, needs_vacuum, eligible_analyze, eligible_vacuum > fields to differentiate. I just rather not hide a score because a/v > is disabled on a table. My point is that instead of introducing a parameter to force score computations, we could just _always_ do that in this function. IOW maybe we could use this as an opportunity to simplify the function while also preparing it for the system view. -- nathan