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 1w8jxU-000pd5-1X for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 19:13:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8jxT-00DRyN-0Y for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 19:13:31 +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 1w8jxS-00DRy3-2j for pgsql-hackers@lists.postgresql.org; Fri, 03 Apr 2026 19:13:31 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w8jxQ-00000000QGl-3jbL for pgsql-hackers@postgresql.org; Fri, 03 Apr 2026 19:13:30 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-66c05fb27e4so3972926a12.2 for ; Fri, 03 Apr 2026 12:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775243608; cv=none; d=google.com; s=arc-20240605; b=Qnl9KlNVrECg6yVTAl5C9lIELXG0UhSy/46QxqDUBngEni1DvU1otxzOLLWzoVuSc1 lwob6Y3rRpy8aKhARf3uQ0nOmryec/Wcdxo9S6HpBj0xU8wNfiP+lPG8RfWwmmCrljCJ UPY/vnukzVP/lBzRuXo/tNqdpTxKZ0/nmw6r51WefUcIFpSaz3SslViN+Y5imsDyma0j cNT2ZHB+Ymvy1IcaXqRDv93AYEqjAhlGMl1xmT3uppwVPnirJYHrw3ALhgv+t0WaWaNj 0dl3vP7C+UBXt4gF+1lrc6Nza/ZuBDR579LGFx3J3Xh4nflux4tj1c5WptRSTvcRWkGB Qr1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=2FGEzm3QSoLRB4soY5n9I/gEp93+NH1bOGLdi5x01IE=; fh=nZz17S7cduBF/IRyfOH9qk0vMyQWtiFjwIUjzCY5rbU=; b=DGMahI17fZt0nU6jWutAyClgUy0zfgxL+yBTWrHqzjWx3fio9OVxn/uNj/tudEEk0Q 5ph3DrqoiwHBVHMJLMnLo01veC8U6+DtIPlaw/MVhJrn7evnTYJN2QLZitShQTtWlOeA 5Bh8lOb6h3ZkvlZE5sGh2sqs/RyO32neFbBXV1tYHtOlDA8+yNaN2MrhgTDQozwJf8R1 J1F+xhTMCRu+80tzQewMmQVBC7Y2KpReM49/bH03uhR6xKHTG0PrmU8eD81wtlGv/q/5 uo6jtYcMCFvqND50SR+1iHzCLAYf1CHtg6yp3/OPZucJyJEU+G5ckUgAQkfmhrf1fAmp yUhA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775243608; x=1775848408; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2FGEzm3QSoLRB4soY5n9I/gEp93+NH1bOGLdi5x01IE=; b=D7Mh1BqTQihEL8Ey+ydxyYa8jzNl26LM+Fv0r+B29WhO5hj5DqQ6EFTH9+lDJabDeM Tw6N8uCVloKmJhSBMB9Qv/C2TCEyFo5GpUb5ZfTWJNyPZv3N7WZSTHr0LvmiVEB+ZOZV /9zPTP1mf8K8wQvVDyznaYVJz9g6c4qaP74r+3wAy4gI/NZqgE9usoCnHp8CGv3eYj9W YipbOgCWYP8p+YdBTRMD1VzvwoeS3UYs/83YgodimeaNQyh0ZJm/JMGISp5ZdaYXSy12 rAzGd1ybubRnSDDi5hyy9i5K65EylUuqnMh7z8MKqI/d+ZNQJwz3AWihDsy9A+i0/9dj 4y8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775243608; x=1775848408; h=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=2FGEzm3QSoLRB4soY5n9I/gEp93+NH1bOGLdi5x01IE=; b=ctdRRAAkRgPPT1oskWzlDnqTR4xJrvKE0w3zRBZJDQX1dTyLiQci0nDhhWg7BnR3f3 92Yb32mFc8MsTvh3bGBqzujAzVb8dHGn+xb1dcFkWI4D5T52mCXLp5wptaPoF6jw7wzn PCW2PceelbBVz8IiGJokh/vylExadYLiN4i8RMYzJkdqy94UhJWu96RO5oJZVfJCqTox 7vNm7+wh4LGB+bxtz0ON8pOEGzxq2tSJnW4GN3Lkvk3idaQZKeGjDFduxyfAJRjEL+hM hu3gOrQdHB4Oxz+RjasNiLJyH1UeEdtz+PYgwNJ17sM1m5YYTCQ6kLOeQTNt1IBl8JKX R83g== X-Forwarded-Encrypted: i=1; AJvYcCXNt2Dq7zYfmBkGGKtqkuYhH3nurPrkpMuGK1zwyKTA4aw0ihBa3SVSD2UTZwD+AW9BpwtzPjkO2BDklbvg@postgresql.org X-Gm-Message-State: AOJu0Yy18x2TtJ2fr9RKgYBCHFi9mBs1uKQRzfrXkr2TY62RFv24ENmE FPvKfxgpx7qz/wMbohYKeiOw+iQxkqISGdObjlHr6ysno/5D2cBzC5Cv0MW+OLFGyc0dKMdRxVL +IVsyPYMYWSR4CNRh107SwcZsF1eGYQTVZmz5Fbs= X-Gm-Gg: AeBDievOzerZ8KnUK8lxp4Ja8Tw9XLlt2OJabgPKbwF/0ksH+FTkYSXDymjxaoLsfz6 4I3iBcPI2czzfUKDOwnpDH+VwNkDcEenOJvDwO5W8IVMzC9eQB5lo9mxc9ImV0ime/VxPPX5JGS 0YuMOTtJPblmRAG9Ay7r303k4ONS/2NTtIVCVn+nW5WK7ZbUsrJUl/KOgCC8puKK1BE+W7ig75D wD9ayHYKT/qUQNMBCmE1UyoZ2IYIjyf1T+aSm+hHtLPNXlSOjI/XMUK/urwfghsuZ+jcjFOQ5X4 9sMRPQ== X-Received: by 2002:a05:6402:234b:b0:66b:eb1d:b22a with SMTP id 4fb4d7f45d1cf-66e3f833ac0mr2274828a12.26.1775243607934; Fri, 03 Apr 2026 12:13:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Fri, 3 Apr 2026 14:13:16 -0500 X-Gm-Features: AQROBzCUVUklq2v41ptPit20uINEl3J-tKXqDjWnVOuq4VhdSXd_RuXc9mtj-K8 Message-ID: Subject: Re: Add pg_stat_autovacuum_priority To: Nathan Bossart Cc: Bharath Rupireddy , Robert Treat , satyanarlapuram@gmail.com, pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Alright, I've been preparing these for commit. Most changes are cosmetic, > but there are a couple of bigger ones I should note: Thanks! > * I added a prerequisite patch for relation_needs_vacanalyze() that saves a > level of indentation on a chunk of code. This simplifies 0001 (now 0002) a > bit. I like this this. > * I noticed that if autovacuum decides to force a vacuum for > anti-wraparound purposes, it might also decide to analyze the table even if > autovacuum is disabled for it. AFAICT this is accidental, but since it's > behaved this way since commit 48188e1621 (2006) [0], I am slightly worried > that this bug may have become a feature. In 0002, I separated this edge > case in the code and added a comment, and I intend to start a new thread > about removing it. hmm yeah, I think this just needs to be documented clearly. I always thought it was expected for auto-analyze to run in this case, and I don't see why it shouldn't. If this needs to be clarified in docs, we should do that in a separate discussion. > * I removed the booleans in the view in favor of just noting that scores >= > 1.0 means the table needs processing. IMHO trying to distinguish > needs_vacuum from do_vacuum is just going to confuse folks more than > anything, and IIUC this information is redundant with "score >= 1.0", > anyway. That's fine by me. > * I renamed the view to pg_autovacuum_scores. While some of the > information in the view depends on cumulative statistics, not all of it > does, and what does is quite heavily modified from the original stats. So, > I didn't think the pg_stat_* prefix was appropriate, although I can see how > reasonable people might disagree. Initially I thought about moving this away from the cumulative stats section, but this view does need to lookup relation stats and if relation stats are reset, the same rules will apply to this view. Also not all views under "cumulative stats" are necessarily cumulative. Some just show real-time data; pg_stat_activity, pg_stat_progress_*, etc. This view does not have precedent in the type of work it does, but I do really think it belongs under pg_stat_*, and not be too far away conceptually from the vacuum stats in pg_stat_all_tables. > * I considered whether to make the backing function per-table and > ultimately decided against it. The initialization logic is a bit > expensive, and I assume most folks will be interested in the full picture > of the current database. Maybe we could add a per-table function down the > road, but I don't see any strong need for that for now. Yes, I did not proceed with this since the common use-case will be comparing tables in a broader context. I don't see a string single table use-case at this point. Besides the above, I have one comment on 0005: Where it says "indicate the table needs analyzing" or "needs processing" or "needs vacuuming", we should instead say "may need". Since the actually processing depends on the thresholds or force vacuum conditions, but no need to go into that level of detail in the row descriptions. That is all explained in the existing autovacuum prioritization docs. -- Sami Imseih Amazon Web Services (AWS)