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 1w7CAP-0053W2-1W for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 12:56:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7CAN-003Kyn-2p for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 12:56:28 +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 1w7CAN-003Kyf-1Y for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 12:56:28 +0000 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7CAL-00000001nxe-2XiQ for pgsql-hackers@postgresql.org; Mon, 30 Mar 2026 12:56:27 +0000 Received: by mail-vs1-xe2f.google.com with SMTP id ada2fe7eead31-60294768235so2986043137.1 for ; Mon, 30 Mar 2026 05:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774875384; cv=none; d=google.com; s=arc-20240605; b=YZzMOZKJa6sJi8I9xv+WNinFLH8sqw1syGU5bWzzhwXgEanocpz3ya1hgKCPpUOPJM 8qpWUoD9yx6rXE/WQ2moDQphLm7zlnhwnFA4FB5oZWsChZe1xx4EJBp6Z+10RpyHmJGq J5laj42L0Z8lZNbV+GTXtA142GD3EqG3278VXxFus3X0gGCbWwx+3hsk8BzhlIonbyXs cRbgrUxuFFL6rrJ/redW4+Y+5Iv9PQN5eBzQdEBmRJACg6QxW7yRGJTHrH3hczGzeJq+ 0yUbdFU2APUyJKfUS/IFgxFUn4B3hqoULP46ZY70zFUDWkeiT/YUvzYCzC41geJGo69M hbLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OQHUcKjUDOaa5IkTp6y6oe0UFqC1GLrhlngLg0CDQHI=; fh=WFKAQop+qyvS/ol/2KGY0GiP0+mgXPx/I0tCsg8QVv4=; b=ee14EoJ2JaMnzkamo+m+Dpfddyj3bck6G7P2etOwNcjaq7kXgDp8bfNtB9wUbyxKZX JyWI5LC27RUQJTP5HHhC/WzdKIMvzDitUojJ0KfBI9fBi5qqCfreF0Ia9jiZEn/GRqGB qqH8Ea1Skfjy2gYekAFHbdyGn1amRXN7kRWGZXwESSyu5wmDZ4K9AIvmIVuveLL89t5h mYOr7Y56c4CPXogk/awyu429EJZilIm4by8ssBKrAQcGPgcPjwTYm8ZhwwYgY2DmRQDt /H8ZvmuYivzHUq4UIjMqgIULo0xZwSVut9txzPvXfDbPdVoRePsfJ2atq5FR8Zl1knFW 1pgA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xzilla-net.20230601.gappssmtp.com; s=20230601; t=1774875384; x=1775480184; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OQHUcKjUDOaa5IkTp6y6oe0UFqC1GLrhlngLg0CDQHI=; b=1x9tZQk94CBRd/XjCgCKBMmYfAt9VhNNf93nM/Z0yEv4X1iBzl0xMX9FXofPVf7fUO fIEqb7XPrItZxvgR1Y7XQGvLNuXdLyHk2Vb09bpZMnRpK0zg3ARx8dtM1zibEENayKmj WBmZE5X2L/eNe1RVa3RuEoxnOvbKr49jVvk+EMotaNNR93Vl0YR1/6kUH+3/xp9DRjkw gW911funOCR7whOkeTve+h6yAyfprkUQGiOPUzAOWyU+0cxNlPyy5q74XYx0/z8kbiar ICFrHaFtfKNt20ijgYPn9dOh7fX1A3crBQvbHn9LXy80Ud99+kfr+BnsJysCD37Zy4Ic N2OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774875384; x=1775480184; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OQHUcKjUDOaa5IkTp6y6oe0UFqC1GLrhlngLg0CDQHI=; b=KVmm6ZTqRrV4WDhnljlh1bCtMScjMgAGfMOEo8UV/pvHHqCLtbsCEMta8f4J3gvjes 80SuqIIwuvi5hia/y3SkHVCjKGhHP0f1NXDshvDKIK/hZhL5ajmAm+M3HsG1my8EJou6 E8f9UAhydTJmCIMco1DhVyE3rgn5JFT94qqNlJETT0OBLSMJFzxPPlEjbEbfo89iVWaL 5NTvgR3VXxxh328uKKE0ZCDNIuk6a9PrRAjY+wxzdUYc2rTj0fcqov5Aq4amhG3g2nyW DUEKNhVdZufiygiLI3iSHYqJfLYShimhz5/Iu4NDe/LRaKcTvHNigwnEjrzWV68Ckqmk FNTw== X-Forwarded-Encrypted: i=1; AJvYcCX2CCSgtTuyx35PFNhA00gW7D0knrHzD8SbmjncmGCX4cQ2rAl1BPMUPTLyYQRyQ+uC/kL+khffNr0961/Q@postgresql.org X-Gm-Message-State: AOJu0YzBGW87jUeUH7fDAiIFiB9ads0L1nFEI5mKxARZOKRuSdb7pK3i FDi4rVW4vV50yXoy+gXzvOMyztKNpAUAbOEHOma2SFmTEIMxeIuU74QAJXwxMTAi2nJDQktiKwL vQrrZ9eg9h1u7wo2/duiShJLvoBToN5TsUXxZtpneHA== X-Gm-Gg: ATEYQzxjZ52taTn6ukFzf+Z7J7OtD+2GDjDiuQ1oFBmJHq2zfvTuc8ayz6ZE9GG9+Yx r8WizhrczprNbC7odT6h/5TfT1Ico9QBMuIKIwxvx44NS2JURVl/CPaLa6qF5CSKkrpZV/xHHUD T1BejT91Kn6iB2ZMXhh4M7gsnhz/0UhIGqQ2Uc1PO5eQKomJ5deAOdoJx7bCXUNxIuTAJ+SzzYi 1NPkah6LfBtEOl2/0rZAUJ5q0+/VRaTf0jjfCDWTLBJsCIWOk/0Mga19nYWQpxiY3HzphPV8qEw ahMg/88= X-Received: by 2002:a05:6102:2009:b0:605:1f22:10f1 with SMTP id ada2fe7eead31-6051f22122cmr1916138137.13.1774875384284; Mon, 30 Mar 2026 05:56:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Robert Treat Date: Mon, 30 Mar 2026 08:56:12 -0400 X-Gm-Features: AQROBzDryhJQxpyrWh0MIItVmUueHvNYBqzsq3kqHxQg4gy7VlYX8TLjDRaRCzc Message-ID: Subject: Re: Add pg_stat_autovacuum_priority To: Bharath Rupireddy Cc: Sami Imseih , satyanarlapuram@gmail.com, pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Mar 29, 2026 at 10:09=E2=80=AFPM Bharath Rupireddy wrote: > On Sat, Mar 28, 2026 at 10:54=E2=80=AFAM Sami Imseih wrote: > > > > > 4. Is the view intended to be exposed to PUBLIC without any ACL restr= ictions? > > > > > 2/ Do we need to revoke permissions on pg_stat_get_autovacuum_priorit= y > > > for all and grant them to pg_monitor or similar? Especially since thi= s > > > function loops over all the relations in a database, we may not want > > > everyone to be able to do this. > > > > I think you're correct there. While the data is not sensitive, it > > should have more controlled usage. It's only taking an AccessShareLock, > > but you would not want anyone to be able to run this since it's > > doing real computation. I think requiring pg_read_all_stats > > is a good idea. Will do. > > +1 for pg_read_all_stats. > Is there a gap here where someone may have been granted MAINTAIN on a relation but they do not have pg_read_all_stats? > > > Can we have the per-relation prioritization computation function in C > > > and provide a per-database computation function as a SQL function ove= r > > > this per-relation function in system_functions.sql? > > > > Yes, perhaps we should do this. So we can have a function called > > pg_stat_get_autovacuum_priority() that either takes a NULL or an OID > > to either return all the tables or just a single table. > > This is a similar usage pattern as pg_stat_get_subscription or > > pg_stat_get_activity. > > > > pg_stat_autovacuum_priority will be a view that wraps around the NULL > > variant of the function. > > > > The case where the OID is passed we just do a SearchSysCache1(RELOID,..= .) > > whereas the other case will do the full catalog scan. > > > > What do you think? > > IMHO, we can have pg_stat_get_relation_autovacuum_priority defined as > a C function to give the autovacuum scoring as of the given moment for > the given table. It's easy for one to write a function to get scoring > for all the relations in a database. This keeps things simple yet > useful. > I don't have a strong opinion on the above, but I do suspect that the most common way people will interact with this is by querying against the view with a WHERE clause, so optimizing for that case seems important. Robert Treat https://xzilla.net