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 1v6Xci-0069x0-N0 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Oct 2025 17:06:44 +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 1v6Xcg-00BfQC-FT for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Oct 2025 17:06:43 +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 1v6Xcg-00BfPw-5s for pgsql-hackers@lists.postgresql.org; Wed, 08 Oct 2025 17:06:43 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6Xcf-0014Oo-0a for pgsql-hackers@postgresql.org; Wed, 08 Oct 2025 17:06:42 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-368348d30e0so59061fa.1 for ; Wed, 08 Oct 2025 10:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759943200; x=1760548000; 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=dZ5ciToM0hIBy+F0EaG1pM4L2xq+v5tKrksS8nq6sXo=; b=lP5Ew92agrnTWu+pEnqyrr41+/klEV00iKPmEhpK8+psIU9SOH16RKYUCkgcqVMOwG aO+5Gx5DVi+dZd95SVkiuZjuwtXQc6+9pDVGOaRONuY2kD1he0W+l2/VL/PoLl7O/Lfx DJ2T428C7ezlRdDUChLktwJfpUVrBSKSBO4M7KVNyldt5+wUcp2sKie6bfMbfhfv8gGx YhM0uxZX7g/YwphFeGM/T5QhghGN0Mcc8RI1O4+a6fKsCgewIGVSw8v96Q99LHBqGrV3 oP5d1nF311AX+bchoSYibc1/UZeJI3uWMPGgcewyLmZah+Xou+FVawJiY7MA9D/WX8u/ cvsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759943200; x=1760548000; h=content-transfer-encoding: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=dZ5ciToM0hIBy+F0EaG1pM4L2xq+v5tKrksS8nq6sXo=; b=Q0qkNqRDMG5X0+OQ3Goo1clFAIikpG0lQp959neE6Gts5Q5uqnrLeT8OiSDFwIjKXT qZKDZkRPvkVQ2ewbPwgyZVfDJLuLWqOFuPYJxX2ym5D/pYzg669JOxDP2DCgnyq8hRFr FyQzYiF326nrDMvOE0O4HH4rWzxRRr2j5rgZ2Z1eI36xFVyHVOS17xkuur0ERkDpSHh2 HNYUBFJvIbZKTwYR8amAfx6J7zI9tmsmwvR1eEo4uGQRI0I6mZwWBP3BFhfVxBjT+wzs w1xBiesiaO1KaT8RKkWQgvWu8FH1XB2/WVKFcmPq9an9lb6BMYdP3gboUyqerhIXaIGG FaMg== X-Gm-Message-State: AOJu0Yyd8QausjkdLsuOaIOL/gz1jQnv1fBz/6GIsKx0zLxHQVcQ0Fn/ +fL9eSTOr63c/U4zHt5/SykIRWffn666YlTBnapvYbKtvelQOKr/GeGzVYygp4JhF8Sv8r5KNVU og79zpDBUYtRtyEUj3YvsEu2dgfgao4c= X-Gm-Gg: ASbGncsDZCZm2Yj8HCfxlLNC8BKJrWIXklQvoTrmPqS+Cn6fOWzuJWUT6kqZyugDQh0 m4VB0DaFCJlSR8hkk4OrTlFgBP2p2dqN0GB3NPJqxJsIiRQJWGSzk7T2rm6llttHUagzJHP+m9S 3BGAQI9C6fKSb8HTZpmaAocuY9kNLiSiURDHKW9Lhyoo4dY9Ne2KhoHFhLBYsVVCz5df15zIpxv gMHgRv5QUTyQVHJP5tn4r5gcSdxwg== X-Google-Smtp-Source: AGHT+IFCs0i8TVqJ5OkZUKnzA/T0kMy0K3e5WnrZWh80vN37D1nJs+14pqE2HFR6d6aWf0VcVGJoo8Xx4Ea12nE7qIQ= X-Received: by 2002:a2e:bc14:0:b0:36d:501:76e2 with SMTP id 38308e7fff4ca-37609d40f16mr10530511fa.17.1759943200100; Wed, 08 Oct 2025 10:06:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Wed, 8 Oct 2025 12:06:29 -0500 X-Gm-Features: AS18NWAfLx6l0yNEWdwJrUx1hVYd_gnbnyUXePx_TDUSjlWP6C-nWg36R-WUOp4 Message-ID: Subject: Re: another autovacuum scheduling thread To: Nathan Bossart Cc: pgsql-hackers@postgresql.org 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 Thanks for raising this topic! I agree that autovacuum scheduling could be improved. > * Prioritizing tables based on their (M)XID age might help avoid more > aggressive vacuums, not to mention wraparound. Of course, there are > scenarios where this doesn't work. For example, the age of a table may > have changed greatly between the time we recorded it and the time we > process it. Or maybe there is another table in a different database that > is more important from a wraparound perspective. We could complicate the > patch to try to handle some of these things, but I maintain that even som= e > basic, incremental scheduling improvements would be better than the statu= s > quo. And we can always change it further in the future to handle these > problems and to consider other things like bloat. One risk I see with this approach is that we will end up autovacuuming tables that also take the longest time to complete, which could cause smaller, quick-to-process tables to be neglected. It=E2=80=99s not always the case that the oldest tables in terms of (M)XID = age are also the most expensive to vacuum, but that is often more true than not. Not saying that the current approach, which is as you mention is random, is any better, however this approach will likely increase the behavior of large tables saturating workers. But I also do see the merit of this approach when we know we are in failsafe territory, because I would want my oldest aged tables to be a/v'd first. -- Sami Imseih Amazon Web Services (AWS)