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.94.2) (envelope-from ) id 1vDRKc-008wgE-Lx for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Oct 2025 17:48:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vDRJd-008Zjz-Du for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Oct 2025 17:47:32 +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.94.2) (envelope-from ) id 1vDRJd-008Zjr-49 for pgsql-hackers@lists.postgresql.org; Mon, 27 Oct 2025 17:47:32 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vDRJZ-004Yen-2E for pgsql-hackers@postgresql.org; Mon, 27 Oct 2025 17:47:31 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-63c2d72582cso8118518a12.1 for ; Mon, 27 Oct 2025 10:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761587247; x=1762192047; 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=+i3juJJIVSMW6qn7gzT1HqEYE5RqXWr1n8u0VF5J2wY=; b=Tehn/tvPHcYhCb9ZHZrzF8MsV65J3YqLQOxcazkyDDa3rMxl3wP9Z5b8ta6A0ES/B/ YhuhMtRMCMuD+0oU4JlbhQ/UYISA6jOuidZsktYKbP/DPNxSRNXFeDvugmVdimfIwTmH SBtuXnQLgaiQuboUyWwsqEVlwBYAZEaOM8KlSA1PmtRajO4zBy5nTZl44kWwoX+XvGRq LlvEDaTSji61yQs0Bd+h9Ctz6o2kFnySpn6Zy21OJflpjKmpMmmjIp4XXiJsIMcZc4YK xVZubT3dkxX3oizCmprGrtsJhl4dz9bcZ7LztiTbJqTqFViYbR70fqfa8gqbO/vce8og WRCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761587247; x=1762192047; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+i3juJJIVSMW6qn7gzT1HqEYE5RqXWr1n8u0VF5J2wY=; b=I4h1xyLXqu7gphxDl1k7ktruv/z6JPcp7SVmU0q+6+Pgya7a6rk4RNduRG/RCv3R14 N+CvcuEO1dzeh2lHnKrS57JSo08fXvXWOocCP/8A31eAOWcImuGT3YkKwRe1iC2GeTXY L7vXuu9+N6lqAy3vnUg2S/9lf/5FH1zgCHVv/zyegAKK2CqHfSuKkZZ34myQgP9uqVow xMLnnAnZ2KnLMHALZoBcHOzY/hX0IfaXFWqlTHHMAZDAUbP5NtlJwMX4g0gA3JLkAdEK m3DYXnjplE0rfYLxCXKncOlB/i5o8Sz1gzxqf6yAz3PuKyD3UAGN6YNFjNhn6a/RKjoz fx5Q== X-Forwarded-Encrypted: i=1; AJvYcCXTY+pJZ8UCNd1O1S3Ag914W6J5PIEEmVGpsrmjehJTo7tXwWA6O3PeKI4aUh5ms2l4ZaQN2MLbHpuEpCNA@postgresql.org X-Gm-Message-State: AOJu0Yyx/UCU0h4t0iQ+3tMn5+ZDu+w8obfiLNoTAp/hXw+NvdobH0HS vnkbR0K4jbGagGv8etTMxETbCJYi6BTSC3qStWpq3WERHDKe+n+/sqc9qNZHd8uchCSDspFS0ye NGxsJ97bjzv7Nvqma7F6UU0RmRa1M0Mg= X-Gm-Gg: ASbGncuQd9A7/bmcwiau9Amb7PvAIgLMGaYv4w+HjUg2l6kfrvFF/zSzyV7gCYWlrQr OH8l+uSKlsnHI1i5k8RL5UZ38zkDGG+Tix/xD3LxCrxNJXG0e/4/+prqnEeT8npcwKFWwjk0w3i iG3WF7RWwZe7j+B8niSGItpyJHfXK8j/pkEcG0ul0VbDfV66mqKwHsag9hjsi09axsbJoGsAlNU 0AX08yuZ4Qs5K96iWadXpdRXMEnZ3Yjy1du3uzOms5y7NBHw1+ioMO4wxc= X-Google-Smtp-Source: AGHT+IFHPV0SaiTKq1o34kv/sknrHYxzpsDxAwK5/lmx3WLKYJXEuD7B0hdVD4WNEZr/SykdCVGpftto3Y56YlufA08= X-Received: by 2002:a05:6402:40d6:b0:63c:20a3:70ab with SMTP id 4fb4d7f45d1cf-63ed81628d1mr722061a12.18.1761587246370; Mon, 27 Oct 2025 10:47:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Mon, 27 Oct 2025 12:47:15 -0500 X-Gm-Features: AWmQ_bm1F824l7hQgeS6uymPdCDE4BD3n-vEEoqRhoXzVO7SKjPlIz9TH9CnI-c Message-ID: Subject: Re: another autovacuum scheduling thread To: Nathan Bossart Cc: David Rowley , Robert Haas , Jeremy Schneider , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I spent some time looking at this, and I am not sure how much this will move the goalpost, since most of the time the bottleneck for autovacuum is the limited number of workers and large tables that take a long time to process. That said, this is a good change for the simple reason that it is better to have a well-defined prioritization strategy for autovacuum than something that is somewhat random, as mentioned earlier. Just a couple of comments on v5: 1/ Should we add documentation explaining this prioritization behavior in [0]? I wrote a sql that returns the tables and scores, which I found was useful when I was testing this out, so having the actually rules spelled out in docs will actually be super useful. If we don't want to go that much in depth, at minimum the docs should say: "Autovacuum prioritizes tables based on how far they exceed their thresholds or if they are approaching wraparound limits." so a DBA can understand this behavior. 2/ * The score is calculated as the maximum of the ratios of each of the table's * relevant values to its threshold. For example, if the number of inserted * tuples is 100, and the insert threshold for the table is 80, the insert * score is 1.25. Should we consider clamping down on the score when reltuples = -1, otherwise the scores for such tables ( new tables with a large amount of ingested data ) will be over-inflated? Perhaps, if reltuples = -1 ( # of reltuples not known ), then give a score of .5, so we are not over-prioritizing but not pushing down to the bottom? [0] https://www.postgresql.org/docs/current/routine-vacuuming.html#AUTOVACUUM -- Sami Imseih Amazon Web Services