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 1vDVzq-00AfP5-Vi for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Oct 2025 22:47:26 +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 1vDVzp-009fHA-QQ for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Oct 2025 22:47:24 +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 1vDVzp-009fH2-Gf for pgsql-hackers@lists.postgresql.org; Mon, 27 Oct 2025 22:47:24 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vDVzm-004anQ-0f for pgsql-hackers@postgresql.org; Mon, 27 Oct 2025 22:47:23 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-592f1988a2dso5830482e87.0 for ; Mon, 27 Oct 2025 15:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761605241; x=1762210041; 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=QPNBq5xUtol9RNiRYR8LymCO/QnDix1oEbx+voDDX08=; b=EAPvT0eoGrlWrAXMwEzFiW8g+wXO8lEYrlMZKw2ilxnUpRBkn1nesM4gyU8wbgH7os V9ExrzVweZpFPuxPZdf5e+MiyBzKSd5SsPNoVl+weVMIOuURdETcAGZCoH74tI6dduyB x9rGju60oTLSBJza2pEhqS90iPGLiTSquu+lmAUq1SH1ph6a1gzXtRJ0znJQ18iIJOqi fWtLzkqdd7Zm4W9h2ermss4CoVWbVfoI86Al7da34WonMPSJ5lL5xT5ybxwcClGxcNs7 Gf1FP7Mzz0Knx1wEQzwineclBlp1pp0JHIi62uu/AC1ATktUr1oUbbOft/j/JaAuoTDu cpmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761605241; x=1762210041; 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=QPNBq5xUtol9RNiRYR8LymCO/QnDix1oEbx+voDDX08=; b=Ic9ZmtHd7keHWUQRnrC/Q+aqn3ITXcNkAVX7KZfF10Yrp/c2rfSZ46kuPIs6rgXOVT tky8aMQiaRPrinIQdu3OyW7S62SKy9JKRBiOVPTvHi6LvMAHXiNs0agXdrvSqQLYvH9M F805j8dsSGbAtx5dv27IuVkcywDFWXXpnwpvwIcxqL9iKuDF0ZW762xP1u1/qVeNnhA7 c5HDKhA9t3ZiLFGn3Yyecp0CpXSx8ajwdgwH/DbQlk5EU79LMEoBxB+asz5j24SKy5Y4 IWxjR/IsrxQZkJyVCaUrO3ZXA2+1tu2/tCDwgQjMwXKqaVtJDwzIfbvShf+xAvnc9qnU iT3w== X-Forwarded-Encrypted: i=1; AJvYcCX2C4Hq9GdzWV2XPfBsaGT0WdZ9Lt+5CmY8JwrTBopN+2Wu75R8ioc2KWKwNnu/bJ8GkMblRAMmHyh3PO8F@postgresql.org X-Gm-Message-State: AOJu0YxSOhabh6AtPUY7a6chkX5QdjZSMqhdjRMuKK45q4VI4UVK8vLh 4XajSx3kVfRdkMhgiE/3ojA3AxPzHvFDQKf3ikW7wk7HhO8OYwrL7syE+AYXnW1kliGAOPOkTGQ 104o2eoq1wyq4Fk61D68S/nNorj/4bdk= X-Gm-Gg: ASbGncuu/+8wAYi6jBhXdc3BXznyeJHtDTNRqEYWj45pwJzTgMQSmnYLv5th43Cj5h1 mSr2LOJvW/sWk/HPxsqYcWcSXLsorHQ1t18KheQ/1j2xog4YZgSS3ehWdYY6sWoG9mk8bn5sGin 5fbzOthWHN3/zy4mMnLyCWWcis3SslkVreE40oAiKi15ZVuUMfIxjpYwmz9lSGVzoF8ilfbqZ8K A1YDV5sewLiDMq4E/p0OIVMp/Di61udjF0djHv6jtvEDdj8hNjIqhvcjA5s/HTL/1UEj6kjqYwh ixdvohk+1vqMOWuMOacWhJ5vkInj6sAqbHoJ6D/0hBRLVu4Ac44= X-Google-Smtp-Source: AGHT+IE5OvbdNk1zuhgiGm8MeVnVtgkKSbj+2AtDzghgaPgJMowOEAYu8y8cXZvCQzkOtAIADpW4JpAVkTKndYqWl1M= X-Received: by 2002:a05:6512:3ca3:b0:55f:6cc3:45a6 with SMTP id 2adb3069b0e04-5930edf7db4mr319390e87.13.1761605240354; Mon, 27 Oct 2025 15:47:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Tue, 28 Oct 2025 11:47:08 +1300 X-Gm-Features: AWmQ_bkYHJe7DRpFBbbtQL0tExZP4ePYjFLBoZ-wtg7c0Cpqen23Jt21iCDnsXs Message-ID: Subject: Re: another autovacuum scheduling thread To: Nathan Bossart Cc: Sami Imseih , 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 The patch is starting to look good. Here's a review of v5: 1. I think the following code at the bottom of relation_needs_vacanalyze() can be deleted. You've added the check to ensure *doanalyze never gets set to true for pg_statistic. /* ANALYZE refuses to work with pg_statistic */ if (relid == StatisticRelationId) *doanalyze = false; 2. As #1, but in recheck_relation_needs_vacanalyze(), the following I think can now be removed: /* ignore ANALYZE for toast tables */ if (classForm->relkind == RELKIND_TOASTVALUE) *doanalyze = false; 3. Would you be able to include what the idea behind the * 1.05 in the preceding comment? On Tue, 28 Oct 2025 at 05:06, Nathan Bossart wrote: > + effective_xid_failsafe_age = Max(vacuum_failsafe_age, > + autovacuum_freeze_max_age * 1.05); > + effective_mxid_failsafe_age = Max(vacuum_multixact_failsafe_age, > + autovacuum_multixact_freeze_max_age * 1.05); I assume it's to workaround some strange configuration settings, but don't know for sure, or why 1.05 is a good value. 4. I think it might be neater to format the following as 3 separate "if" tests: > + if (force_vacuum || > + vactuples > vacthresh || > + (vac_ins_base_thresh >= 0 && instuples > vacinsthresh)) > + { > + *dovacuum = true; > + *score = Max(*score, (double) vactuples / Max(vacthresh, 1)); > + if (vac_ins_base_thresh >= 0) > + *score = Max(*score, (double) instuples / Max(vacinsthresh, 1)); > + } > + else > + *dovacuum = false; i.e: if (force_vacuum) *dovacuum = true; if (vactuples > vacthresh) { *dovacuum = true; *score = Max(*score, (double) vactuples / Max(vacthresh, 1)); } if (vac_ins_base_thresh >= 0 && instuples > vacinsthresh) { *dovacuum = true; *score = Max(*score, (double) instuples / Max(vacinsthresh, 1)); } and also get rid of all the "else *dovacuum = false;" (and *dovacuum = false) in favour of setting those to false at the top of the function. It's just getting harder to track that those parameters are getting set in all cases when they're meant to be. doing that also gets rid of the duplicative "if (vac_ins_base_thresh >= 0)" check and also saves doing the score calc when the inputs to it don't make sense. The current code is relying on Max always picking the current *score when the threshold isn't met. David