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 1w7GB9-0057pI-30 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 17:13:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7GB7-004z4w-2t for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 17:13:30 +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 1w7GB6-004z4n-2X for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 17:13:30 +0000 Received: from mail-vk1-xa30.google.com ([2607:f8b0:4864:20::a30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7GB4-000000021v4-0SYy for pgsql-hackers@postgresql.org; Mon, 30 Mar 2026 17:13:28 +0000 Received: by mail-vk1-xa30.google.com with SMTP id 71dfb90a1353d-5673804da95so1656169e0c.0 for ; Mon, 30 Mar 2026 10:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774890805; cv=none; d=google.com; s=arc-20240605; b=S8RwBL5zuMSmmieq43vEUSskYSYnn/WGHplEGC8Ia0qkztiMomTr60S7VWgB8EUmF4 Th2cmOUE4AlUIHMh2UVjfa3nx3SCJrOhfI2yy5clYIy8JMvYIJ94r7Oqc58RjXTgnxx3 m3YxG2mhRYbB80WUhcvNl0DlAk1dlNGVfbL6IXGVMAHx3Lqd0RKtmx6zQtEEWoDdTY8H vCeXn/iwJNi2fTWmpGMLleir7prcpisv2d7JmrtK4uNJtSleA6GNCIZzoUFu+g6qThr7 ueE7NzBnIR4RcSSzAN9k8WrikRHY1U0O2PaBKuzOyy9pfFH5QHFFQJ6rpFOCmC1jvoEF KHnQ== 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=xxRObZywuQvv8FGEl3IBShtBGBobFlMLsFLCRnYV4oc=; fh=JuyHPA+AvuY1NxE+fs2FTxuxQ3HhO1wwUrvBib+IUfo=; b=WWyne6x6QWynxUnfml+HY9M3OIcV49OUYCOH+D8m9NUR/rCzAgqc38+9n3b4yK7Zee HKZhZWx52EzqwU81LYmn0gNQg3DZL4sjx/QKVmVRCgK4WqLdJIMFBtba65zWqRabHj/L lDhrA06cVkqk4Y7AvF9UE1IFxYsFjfXhjT2/F2ViJ3DFbsY4G6h4Oo25Tet91iMEnTyC eAMxHUEo+/4h0Yz9aCWNSuJgSrCAn1qeXEGZcvXcXx/RZGAd9fYYI1QwJoLKYITZYJng aopj39Ji8dhmUqZFhiPAdkOfwr0y4mBce8xLVMiKKNoxVe2ne8lwL6Fa7hQ7v/LiHQgw OBFg==; 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=1774890805; x=1775495605; 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=xxRObZywuQvv8FGEl3IBShtBGBobFlMLsFLCRnYV4oc=; b=uoz4c4HwmvCP7mYwh3j5CzI/kW2kgglcv/UXQMY2dn8N+hrsfRWUyjQ4ZqbazH0kLJ MrLA3L4hMayzijWkt3LSPnEsSpqxldnsWqgsW7AIqyHZklGKaQBubI4RVaZMCmR3+zJG ublSn6b/UDZaCmHaS0Ii/Li7H1D8qOonAmleV27X/gbgnMo/tPTjOSeByCz3AnVve6W1 2dJiqSjz5Usf0jP4rGV4VQxJt3w64DGLiFf+hGIrJ1QGKpAUByaZYr6453eT53j2LR21 ZhdZ2ni6Z0ULmYipltLV43TYTiuGPZRRl3D7S2YcYZLmL+WNipz8BMlxWlAALPxnNCRj OZug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774890805; x=1775495605; 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=xxRObZywuQvv8FGEl3IBShtBGBobFlMLsFLCRnYV4oc=; b=ini6hohtdmnu8TGrpzOpUfQCw426ItAeMaFOC6J5ZVk2s9q/tlQWAjLG8SNWjCWrOS qfVLWuUgPAdnbz/60VL+KJZ7HpRNhbnq3T3jo59kxm5wKGpJwLLwlOxfaPEollLdCTJs REBBb2w1IyBco0cHnpcznOeLw1wuB6gu8/fNv6tXZDciWTW2AgSRqa3JxmLS4hLMHDDm 9VAuGnz99zD/JcNjaS0mJzZPTaOIQjc8c8FjOY//TFEG5x3SPAQYyK4r2jfsi5oa690N 6a9i60F76HLXFBem7sMZ29o+uEzOz96WzELVDHHBz2X9tgvIt1U25jclRqzr0p+m+o2x 5QAw== X-Forwarded-Encrypted: i=1; AJvYcCUVynsxzt21gYc1aba1VS+Pt+Kh/eErXO7Z8Zj591/iy8eZcUSW8hlyn3jxsFuGciSCIknviBalqi0hcBqj@postgresql.org X-Gm-Message-State: AOJu0Yxp6d+5tu7bivmgyj0/0OudXp3BKVbRVf6U7hNZukfs3qu9cTuK l6Y8pPACD4/Yuz/mp8zxVWuE06I5JuAie2UJnpYGtz33B4ftnFVO4wFpKxZ8cpFr70mt7RL+JJq cSJhUD5jAzBdVeBwtc7k7vX8xvjTnxBSqMLfB2KNKjw== X-Gm-Gg: ATEYQzx8ixd1vzPNIbm+F6kpD3ddZhZVhEp7yQljr4BA2auNqTbN7hBS3X/RqBSiroS hQ54XpvVZTnR3RTBem1PJJm7xyepKF2gOmWhR5Q2x03j6XIJEPKXWIP3mBO1LT03JUUG+HVM54P /5t2mPZszG5qSoRFCo/oq+ussTezN2fywdTqBh2GvZ0CDq0b05dHxNUWVFxG9fgp1T1PNNJrU2k vnpkt4tdl1ANaJLyHxNoR9Hlbav4PX54vxosY8wc/HYc9mSJF3zOQGFn6O5Cq50R4Mc1V+utfYw ZfN1eOI= X-Received: by 2002:a05:6122:e202:b0:56b:da56:b261 with SMTP id 71dfb90a1353d-56d4a4fb92amr4867522e0c.5.1774890804796; Mon, 30 Mar 2026 10:13:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Robert Treat Date: Mon, 30 Mar 2026 13:13:06 -0400 X-Gm-Features: AQROBzD6FvA9yclsB-kIpQ6CTwmJgVpVZSnl7-kdjEgieNMSvDPGu9X1OdRzGWE Message-ID: Subject: Re: Add pg_stat_autovacuum_priority To: Sami Imseih Cc: Bharath Rupireddy , 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 Mon, Mar 30, 2026 at 11:17=E2=80=AFAM Sami Imseih = wrote: > > 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 r= estrictions? > > > > > > > > > 2/ Do we need to revoke permissions on pg_stat_get_autovacuum_pri= ority > > > > > for all and grant them to pg_monitor or similar? Especially since= this > > > > > function loops over all the relations in a database, we may not w= ant > > > > > 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 AccessShareL= ock, > > > > 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? > > Yes, that is possible. MAINTAIN is a per-object privilege granted on a re= lation, > whereas pg_read_all_stats is a global role membership. They operate at > different levels. > > I don't think one needs to have MAINTAIN permissions on the table to see = the > autovacuum score. DBA Monitoring users are usually separate from the DBA > operational users. > > I think pg_read_all_stats is the right permission here and it should > be implemented > similar to how pg_get_shmem_allocations is done where the default permiss= ions > are pg_read_all_stats. pg_monitor inherits pg_read_all_stats so any > user with this > privilege will be able to access this view. A DBA is free to also add > privileges to > to other users if they wish. > > This is unlike other pg_stat_* views that have tuple level permission > checks ( i.e. > pg_stat_activity), but in those cases the permissions are needed to > hide sensitive data. > This is not the case here. > I don't think we are in disagreement here, I was just thinking about it the other way round; someone might have MAINTAIN privileges on a table and want to see what the relevant "autovacuum score" is before taking action. If the solution for that is to give those roles pg_read_all_stats, I guess that's ok, but there was probably a reason the permissions were limited in the first place. *shrug* > > > 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 fo= r > > > 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. > > Yeah, after sleeping on it I actually think the most common case will lik= ely be > ORDER BY score DESC LIMIT ... because you usually want to see where your > table priority is relative to everything else in the database. > For the rare case where someone wants to look up an individual table, the= caller > can just use a WHERE clause. So, we should just always do the full pg_cla= ss > scan. I don't see why we need to complicate the c-function more than this= . > I think we are also in agreement here, although based on my experience, filtering out things like system and toast tables will be common, but I don't see that changing what you said above. On a similar note, +1 to your changes in v2. Robert Treat https://xzilla.net