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.96) (envelope-from ) id 1vyC7D-00HWfI-0n for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 17:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyC7A-000RaU-1c for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2026 17:03:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vyC7A-000RaM-0h for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2026 17:03:56 +0000 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vyC78-00000000Z0c-3YM5 for pgsql-hackers@postgresql.org; Thu, 05 Mar 2026 17:03:55 +0000 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-40f1ffba6a0so1820849fac.0 for ; Thu, 05 Mar 2026 09:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772730234; x=1773335034; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=5wm6+eWdFouJcmh0X0FYdh5nmItrWPewt05+Xg6SasU=; b=Sogyccmnazv+lZ4EPdmz1ulRuQufT4AvaZzu/fKxMmJlER3RV/c0Qh2+LOYAuXSXxu iqi2M745e+F0nbUwb6jz2Txcsv7x1RcTlbc181dzjWcZE6wsT+CDaK2RLhrAciOppZ+o 54fgfzvPxVDHqx0TL/exf1Vl8LDXPJgQSV2pFqtnXu4DHqj5qntR2o9TByGZgzQifln4 3wISeWVJCWULbQxO11/hRmLTnwpaWBnGRuTJh9scYYu1REd2ACrM8WiM0UM93KiX8teV fUg+jBR9mrMWVAfllWz6MkMQwYsnC6ojIkPIYE8mMXblxNHFM2FVrfpKY2COYdmXO8JP TyfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772730234; x=1773335034; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5wm6+eWdFouJcmh0X0FYdh5nmItrWPewt05+Xg6SasU=; b=SCPRkgi1xfdMMOF7rG/28zhT6PnUsSmdQM2voDaGTnr4kq1fdF0liVCg/5sDZOy8mW 8V6VvBTBxtJ7hxM44qIKxDaKye3GdNvGWq8rKrWTdmTNZOf+jFKsW71dRFkPW0EFEtUs g/Svs6vYY2F/E3X5XkxVlAwl2JNxYEolYPmyAEvupiGWy94f7K9eCu+9xilSmIF8Gbzf 2m4fACu4O/G6oTKQejoM8p1Mxd5Op4BVL+QwIcDhUYjpdo+UXYaZ4862mtD/0NoZOIBT 4hChdIuHc4m3VcfIGAdmF/nYo3EUO53FCLJ9PrcRo7sMMi18hXt5uZ8Sqg5Rcpjb8aye R/kQ== X-Forwarded-Encrypted: i=1; AJvYcCWI/sL8WQaxpNwWD6RpyAmlKjWmo9iU5DgVTohJG6Q3ZJsb4HrYweiQ0XwoJj/maBs+f6lk5BkGQSOhYoyf@postgresql.org X-Gm-Message-State: AOJu0YwBrBkQEHnn+EdEQzEcc5dkL9Gd/QnHrAztEz4ICNqVltIJxGGq aVuU9Ihb7/H3CrhtexKQpDtM+wbuJ0+nADX3BaTWOG7bJsVM445Ucd/E X-Gm-Gg: ATEYQzwvKwc0ZmdrGzTBCaP42z5TwyrrOqVuIcdnucbVbpLKt1BaFLBneRsyT0DlvRc 0HzW/fmc7lDnL5bD/LFSuCSsqEdGsdmQ6NZa3w5BRKBPD6dNUQ7h4ffcNj6704Gh6AaRB/lRbsG brKzDOkLbDwwMCS6AwABQTuYTWlgdRhHJEFlLJqv0eh5VXaLnbC3npMR4hMj/1b8UG6+Jew9ZVt cFF85zQuZ2VSBxTY/JaIv0HgftxT5D0GDI22/tarrqqRCtbr+ZZiG0Gi9Fu2997dvJa7p7nFTWY ia1c2TQKe/Q/kHARL7okHPxN70GLkgGi0xU6Qw/87Pi3+pkHaCY8t01ZKMa/G0R/Zf9R0YO+sb0 +x36ChEFpkqIcM6CVJiqjlGK3UpFQGV8wMInYw5Hf6aUqn+6D8pNPgAsMzWsN1ynTJhAaX5NBr+ yAnguRmnSCPzGTsiKZ8PbFrQTrEtLNzCKZ9ZaM8zgU7NiF4lxhXg30Ra8xKPucOsuMKR85CW2hP W58kVw+fkyfQI2RFmzvJw== X-Received: by 2002:a05:6871:3296:b0:409:7a01:6e2f with SMTP id 586e51a60fabf-416dbc92b82mr202342fac.11.1772730234013; Thu, 05 Mar 2026 09:03:54 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4160cff1aacsm19919654fac.9.2026.03.05.09.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 09:03:53 -0800 (PST) Date: Thu, 5 Mar 2026 11:03:50 -0600 From: Nathan Bossart To: Robert Haas Cc: David Rowley , Sami Imseih , Robert Treat , Jeremy Schneider , pgsql-hackers@postgresql.org Subject: Re: another autovacuum scheduling thread Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk My apologies for getting distracted from this work. It might be a v20 item at this point. I haven't addressed any feedback since the v8 patch, but I did some testing. On Mon, Nov 24, 2025 at 02:59:33PM -0500, Robert Haas wrote: > On Sun, Nov 23, 2025 at 4:55 AM David Rowley wrote: >> One thing that seems to be getting forgotten again is the "/* Stop >> applying cost limits from this point on */" added in 1e55e7d17 is only >> going to be applied when the table *currently* being vaccumed is over >> the failsafe limit. Without Nathan's patch, the worker might end up >> idling along carefully obeying the cost limits on dozens of other >> tables before it gets around to vacuuming the table that's over the >> failsafe limit, then suddenly drop the cost delay code and rush to get >> the table frozen, before Postgres stops accepting transactions. With >> the patch, Nathan has added some aggressive score scaling, which >> should mean any table over the failsafe limit has the highest score >> and gets attended to first. > > Right, so can we use that to construct a specific, concrete scenario > where we can see that the patch ends up delivering better behavior > than we have today? I think it would be a really good to have at least > one fully worked-out case where we can say "look, if you run this > series of commands without the patch, X happens, and with the patch, Y > happens, and look! Y is better." I used the xid_wraparound module to artifically induce a situation that looked like this: table_name | age ------------+------------ t1 | 1950000020 t2 | 1560000016 t3 | 1170000013 t4 | 780000010 t5 | 390000007 (5 rows) Each table had 1M updates, and all other tables on the cluster were frozen. I created the tables in reverse so that t1 is listed later in pg_class than t5. Without the patch, autovacuum goes straight for t5, and then processes t4, t3, etc.: table_name | age ------------+------------ t1 | 1950000021 t2 | 1560000017 t3 | 1170000014 t4 | 780000011 t5 | 1 (5 rows) With the patch, it processes t1 first: table_name | age ------------+------------ t2 | 1560000017 t3 | 1170000014 t4 | 780000011 t5 | 390000008 t1 | 1 (5 rows) I'll admit this is a pretty extreme/contrived example, but it at least shows the intended behavior. As alluded to elsewhere, this prioritization work might be more useful once we are automatically adjusting the cost limits in more cases. -- nathan