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 1v7pYN-008UTi-Ou for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Oct 2025 06:27:35 +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 1v7pYK-000fta-Ck for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Oct 2025 06:27:33 +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 1v7pYK-000ftS-1K for pgsql-hackers@lists.postgresql.org; Sun, 12 Oct 2025 06:27:32 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v7pYI-001hxk-1B for pgsql-hackers@postgresql.org; Sun, 12 Oct 2025 06:27:32 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-57dfd0b6cd7so3761463e87.0 for ; Sat, 11 Oct 2025 23:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760250444; x=1760855244; 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=ONxcWNnA8oGvR0Ab+/xFP8n9yMlNa8xpNR3hiKedH3M=; b=nFqBPZmn58TGER3WX96Tsn7/1K8ZnzJ6YNJ+R71+5JXt/q5S9J6S02ucrqlmE4/3C6 F7HxxweiF7+hYIyUD8iKNV4cE4U0512nTemot5tw/uO2T/vE9RENaKVxqb8KtTqlAZ94 J/uj0e++GMopUvPg0YKk9wkC9FDTFqyQPbvtjDKFxgZ/10hIV4JQ1n0E8HdQm0YdNcVS tCT2MhlNUPVaqc/VV/gnCP9RqwQYA4kXfC0vrjVJAz+4d/514ZR/kyed1rkaeEtPo9SH mbH0f+rIUmXHkjM8fowvVwlx0ykXZJf0V8GNCKcWGVjQms1GDBk/xa6124Pypw47pRZu ZY/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760250444; x=1760855244; 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=ONxcWNnA8oGvR0Ab+/xFP8n9yMlNa8xpNR3hiKedH3M=; b=cptEHtL7M8DsekkYfKrIzIo+tatoELHWhhFRlF8dPM7TXFJGbH9Oiixbw/yzEYdF6U a2ISbObrjuMHZpL1YSfXtGPE2Z960DTepqBqQnFVdWkITG24BHFr04sLMTFc6KN+d9jW OGgFoi4IrK+eFkk2YFvJ9WRmSyxYt8RFpYJbdh9ySRqLmTNDPQeyTcEiVRpPscxAVKHH Oll7gdhI794LatQ3g9GQnZd1q0R99eeMbrvGL3dXRc6lJQDllFTUnlVJDErxox4ZTnD1 Q1D7WiIdzwyG25Agdk6woEeAa33WpvF4/72PCWgGHK0InKsICh3lbymvd2MZQcKf7DBD c0PQ== X-Forwarded-Encrypted: i=1; AJvYcCWXZH6jW23jcGiUtohqiQZyJaDEBknSdMaylNwwSA6Ge8Ip519jtvI2l0yAakFwZ0zQFbtvOuKpFsk9mpo1@postgresql.org X-Gm-Message-State: AOJu0Yzmfb63ZAMsyMcykC32NY7McnhwgFRrsD3X2lvIjppwVfjiQL65 8Yc2Jz5mwzjuXEXM9BDmQHjjXzkmuvIhWOuDVj8iZh84/t06rZwzQ74dubXRCIg4PVQ2tQDcoZa PE3GnQfUupRrcAYXZ/cC8H8LIaq8SWrM= X-Gm-Gg: ASbGnctc6PNHevEviS3iQWuz7Q+fiNP5m6iv/rwgXlFBmgNYcc/vbPn1B4sZIeLQfxv Kb91Pe/jrzXNoz1t/7E6rr6J8fhgggWHAh656K/CDcYu4EnwrdKMxkjvd9dWDOCo15xGMev4qyW OVmFAgIZLe7CHy7736pdSGV5l+9BFzUHS3LcjhgoM2Zrsb2xTZRHEmXrojdeVO3eIW36HpgyVr2 BTBDmbJOsttOSqIh3VcsyGYaKf0dA53wOafpFVj5mnUvAz06sk4Xj4sjZR9gwPJtvH2Y09gJxgi KoYT7wtgegcNabsShd4bSXEBQ8W6QgjkMVNf X-Google-Smtp-Source: AGHT+IEeFkdxJ8z6oLvDeXkVbe1MD6Ns3u2PWkpNCfzbQhBJLSJJBybVCxkWyLDJVRy0WAl7/y+SrKZ1OOBkJQzhuq0= X-Received: by 2002:a2e:9a12:0:b0:336:7c7c:5ba5 with SMTP id 38308e7fff4ca-37609e10855mr51039641fa.23.1760250443678; Sat, 11 Oct 2025 23:27:23 -0700 (PDT) MIME-Version: 1.0 References: <20251008164057.6bceb9ed@ardentperf.com> <20251008172727.3befd129@ardentperf.com> <20251008182520.6e05a8b8@ardentperf.com> <20251008184740.328d45de@ardentperf.com> In-Reply-To: From: David Rowley Date: Sun, 12 Oct 2025 19:27:10 +1300 X-Gm-Features: AS18NWDacR1fID_rjGVBNqLwNx4PPaK8zupuEf2siB_6GT_O541KehIleRifUbk Message-ID: Subject: Re: another autovacuum scheduling thread To: Robert Haas Cc: Nathan Bossart , Jeremy Schneider , Sami Imseih , 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 On Sat, 11 Oct 2025 at 07:43, Robert Haas wrote: > I think this is a reasonable starting point, although I'm surprised > that you chose to combine the sub-scores using + rather than Max. Adding up the component scores doesn't make sense to me either. That means you could have 0.5 for inserted tuples, 0.5 for dead tuples and, say 0.1 for analyze threshold, which all add up to 1.1, but neither component score is high enough for auto-vacuum to have to do anything yet. With Max(), we'd clearly see that there's nothing to do since the overall score isn't >= 1.0. > - The wraparound score can't be more than about 10, but the bloat > score could be arbitrarily large, especially for tables with few > tuples, so there may be lots of cases in which the wraparound score > has no impact on the behavior. That's a good point. I think we definitely do want to make it so tables in near danger of causing the database to stop accepting transactions are dealt with ASAP. Maybe the score calculation could change when the relevant age() goes above vacuum_failsafe_age / vacuum_multixact_failsafe_age and start scaling it very aggressively beyond that. There's plenty to debate, but at a first cut, maybe something like the following (coded in SQL for ease of result viewing): select xidage as "age(relfrozenxid)",case xidage::float8 < current_setting('vacuum_failsafe_age')::float8 when true then xidage / current_setting('autovacuum_freeze_max_age')::float8 else power(xidage / current_setting('autovacuum_freeze_max_age')::float8,xidage::float8 / 100_000_000) end xid_age_score from generate_series(0,2_000_000_000,100_000_000) xidage; which gives 1e+20 for age of 2 billion. It would take quite an unreasonable amount of bloat to score higher than that. I guess someone might argue that we should start taking it more seriously before the table's relfrozenxid age gets to vacuum_failsafe_age. Maybe that's true. I just don't know what. In any case, if a table's age gets that old, then something's probably not configured very well and needs attention. I did think maybe we could keep the addressing of auto-vacuum being configured to run too slowly as a separate thread. David