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 1vBeka-002PKJ-TR for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Oct 2025 19:44:00 +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 1vBekY-000yF4-H9 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Oct 2025 19:43:57 +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 1vBekY-000yEs-6G for pgsql-hackers@lists.postgresql.org; Wed, 22 Oct 2025 19:43:57 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vBekU-003fS1-2c for pgsql-hackers@postgresql.org; Wed, 22 Oct 2025 19:43:56 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-430d4cf258fso318105ab.0 for ; Wed, 22 Oct 2025 12:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761162233; x=1761767033; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tzvv2XUrQ8zL7UJIlZAOFGS5nuk8DRx+eU9PWh1i2G4=; b=enq2lnbvaKIrmg06fgDH1UvgNhnu7J8DC9Es1VppXizprHP1MoAAdOtvBtkUI3SgLj VTpz3/dNF7dgcs2QUDZA+dlu0ogma3jspp4z+qveQ1JgegX3haRNWlw4kGREZ2zTxDsv wwi/NF1ZvTdzqUttNc6A9hNcI1NVe9JHHLfYymh+VVwMBNGxlNuYSKwAHzTpPb79aPQC JOODfnWI3eAeHzqjLLUEFfiZzhV3yRpZ/kE0Hu0M0SpTb4zLiWXaql2JzUdgB7qVekol SxpHqnRyj2JVZAFMPLLHPCyg3wi3aMqdmR7RdlxMvRIh6PuaAeIkthL6a0T1GYwuNgm5 R89w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761162233; x=1761767033; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tzvv2XUrQ8zL7UJIlZAOFGS5nuk8DRx+eU9PWh1i2G4=; b=dXzpZIaJvjvGpxbnuani5awPAKxXHHKaLS7MOe6PGKaf/wXkEC+ozmwZVDcCN2ZOVP UCRZXr5+8xVlW2zuP02ijAXpMlOZswiEuL4Py5ByN0mHHsF50jxlDR2RESmnd5At14Dv iNkKOeXWZxrxBxUMyKoi5FFzzrDkd6HetppdytD4kznvabX6Cap13AC5owrvXTjKZSCU Cdlgdq4S/ul1hZaLxzvN+LyZ6tPuaEqlAxin67EKAe62hPKcGVyJ+sQgYMjFDkoIs8vk L8vECPEYL8IN1xPmEC4lDlX5qTXXJBUKTnTxeRTFy6Cdmd59eQP9aHeE7XGEZe8dnGTz vNTQ== X-Forwarded-Encrypted: i=1; AJvYcCVePCskBZD/BaeiyFWK+HXlP2HE+IJAOhAaLioFfTRx3qzeg0kBjZedAHfrQsTYtsiWQNJQkS4KK4lENqqt@postgresql.org X-Gm-Message-State: AOJu0Yz7q72j+LKlTX4hSIoiJzzKx+Nu7H9iJ3HL6X6F3+gJlTsUu+UC eeuHLBO/5g4mjpSQTqLWjKLlRXUp+MGsm46yY1T1UF9ZpGuiWjUkWQF4 X-Gm-Gg: ASbGncvWATSEr7SF+AfNpn38PclCOjY72DOOu76JBfxNYH4U0QbNbuGMdWmR8iPGskx +AUyAshvYP7XI9Uvbmlj+dbTy0H8ET1EMEz5Qx24wN1NWneDsrd90+LkMffUd/KapsPk4KW0kCi 0kI7RqsHAVpkLIC3O68oIlpF17At1MrQqWfy4x6fgsvSg1EOYSKDoxYbC5wM7NgBFvbLX8uLSYN RWLkAy+suzutizmPZL38jzmF3o9GE7Ybn1EghUtnuBoAuKRkX7YJWrbweOiXdyXq0EDcpI9M/8w iMc/IoL+Wa4a8ko7pdRsWcqKfOtQEpuZfjjdzQIhe1D7tc+Qz32s9Z0XuoPJoY2tkkJyqpTUhIp qOmQx99v0rFUA68fP7XZueivckybUG10xf419tkJEn/+TmWkZBs2bR8oezpZrwhy/+O1GI/UYuv wQnZCdzR/3I1MtBhAZohKlg69OvxUo7QCjpzQ48ae8S0WlGjtn545lA+1kciCC3B0RJw== X-Google-Smtp-Source: AGHT+IH9cnGe16VKQDuLHPu51GwyebOMq504HQ6WO1M+2qgCI06tN/LfE7QoH2PEZbbx+LYRDnnjGQ== X-Received: by 2002:a05:6e02:1c0c:b0:429:b49:7351 with SMTP id e9e14a558f8ab-430c527d2afmr267927065ab.19.1761162232551; Wed, 22 Oct 2025 12:43:52 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-431dbc3178fsm641265ab.11.2025.10.22.12.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 12:43:52 -0700 (PDT) Date: Wed, 22 Oct 2025 14:43:50 -0500 From: Nathan Bossart To: David Rowley Cc: Robert Haas , Jeremy Schneider , Sami Imseih , pgsql-hackers@postgresql.org Subject: Re: another autovacuum scheduling thread Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Oct 23, 2025 at 08:34:49AM +1300, David Rowley wrote: > On Thu, 23 Oct 2025 at 07:58, Nathan Bossart wrote: >> I'm imagining something a bit like the following: >> >> select xidage "age(relfrozenxid)", >> power(1.001, xidage::float8 / (select min_val >> from pg_settings where name = 'autovacuum_freeze_max_age')::float8) >> xid_age_score from generate_series(0,2_000_000_000,100_000_000) xidage; >> >> age(relfrozenxid) | xid_age_score >> -------------------+-------------------- >> 0 | 1 >> 100000000 | 2.7169239322355936 >> 200000000 | 7.38167565355452 >> 300000000 | 20.055451243143093 > > This does start to put the score > 1 before the table reaches > autovacuum_freeze_max_age. I don't think that's great as the score of > 1.0 was meant to represent that the table now requires some autovacuum > work. My thinking was that this formula would only be used once the table reaches autovacuum_freeze_max_age. If the age is less than that, we'd do something else, such as dividing the age by the *_max_age setting. > The main reason I was trying to keep the score scaling with the > percentage over the given threshold that the table is was that I had > imagined we could use the score number to start reducing the sleep > time between autovacuum_vacuum_cost_limit when the highest scoring > table persists in being high for too long. I was considering this to > fix the misconfigured autovacuum problem that so many people have. If > we scaled it the way similar to the query above, the score would look > high even before it reaches the limit. This is the reason I was > scaling the score linear with the autovacuum_freeze_max_age with the > version I sent and only scaling exponentially after the failsafe age. > I wanted to talk about the "reducing the cost delay" feature > separately so as not to load up this thread and widen the scope for > varying opinions, but in its most trivial form, the > vacuum_cost_limit() code could be adjusted to only sleep for > autovacuum_vacuum_cost_delay / . I see. > I think the one I proposed in [1] does this quite well. The table > remains eligible to be autovacuumed with any score >= 1.0, and there's > still a huge window of time to freeze a table once it's over > autovacuum_freeze_max_age before there are issues and the exponential > scaling once over failsafe age should ensure that the table is top of > the list for when the failsafe code kicks in and removes the cost > limit. Yeah. I'll update the patch with that formula. -- nathan