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 1v7Gxd-000ApC-1s for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Oct 2025 17:31:21 +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 1v7Gxa-00DPro-Nu for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Oct 2025 17:31:19 +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.94.2) (envelope-from ) id 1v7Gxa-00DPrg-6A for pgsql-hackers@lists.postgresql.org; Fri, 10 Oct 2025 17:31:19 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v7GxY-0014ay-19 for pgsql-hackers@postgresql.org; Fri, 10 Oct 2025 17:31:17 +0000 Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-42d8b15548eso11399455ab.2 for ; Fri, 10 Oct 2025 10:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760117475; x=1760722275; 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=gJ3kVusIpAIS0Qnje34MBz+Xxgfod55Usm3Axa4S7xw=; b=MuL7BvaouDfBvRhPNh3BNwxGxy4B/tCQmZU5qkj9Ayz3MKRHPQVNu1opS2/I8JVlBZ 7Z0JWT090fMqRn7NWlMu07mZEiOMgdpqeowp6RQegqgrwyjQJPReqe/h0V+HhNfRD8ft RLMQMfOBaosybccS+CzVpFDn0oYVsn/da6LfLFHRYsOjz92WXSavrWuC7FIMasT+N266 U1HRyfKa7uZxvOg/hq+NTceS0iIhMIrsTFiPQbpQ08jHl1+mS1UZzVCoBO4xULx/P2n7 wOX/zmVf1F5JAcY/IEygvhp6rioZrnuhTcfm2fCxlsEbPXwSB0iUUQBpTlyyVaIfWGvh 4xvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760117475; x=1760722275; 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=gJ3kVusIpAIS0Qnje34MBz+Xxgfod55Usm3Axa4S7xw=; b=PTAiqmzPRaFiEH4hdcQFld6ZF6zM03LIec61QupHhOE8KLB66jjfxVmFmsZKnTOwbA 4cH1kWv9G3A080LJTQG6S01lfl6AmrAg6zGcFE3NxBwrZNfOJshzdPi2Ix0Zw1yUMSvh isqAvBl8Pg2PENxUkvuewx5txw9Fsm8LPoZqbqQ9eUnhsx6rsc4kp1OVm4ADApHwZV3U K/mDp6g7h3C3W4b81vuXdsGSigngzJQTIw3HXmZZT87V0o/zQImM4L4ue404aRC+Hj5v 63dHt8Buy9d3yu/rHyhOlC12+AD6U6LyiWT9CMffo0A53PLjcmVvcqDrMABC1FiVC+c+ iPEw== X-Forwarded-Encrypted: i=1; AJvYcCWiRj8baiQw0Z8K6UthxJFi+hc/YJohRSOKJi7UgNJgaEgBI2Oj2pvegzfATR5UYWtSB4sx5SBAqwxImIpF@postgresql.org X-Gm-Message-State: AOJu0YwkAZjEZWFZxTKYXdj+l7TSEBGLIGQ+eHf/iuJZ+TlqMq7rgK14 8prOBDrndMPXeU6DfL42E9Sol1ZYM2mSSkASs1ZAbHF9xRYhagDow3p/BUNYAQ== X-Gm-Gg: ASbGnctZ+bTlt4athryXp1A/bZwxZqw95Ue/3RJECHPqGugkJ6ZmbtzU9AcdiCuRoYO TBfRNhIf0o1nMSIKt+VHaiCNJsfY+xQUJazFqiFpps1L82pJ7DPliKaQjX65tQxsmvu3a3xCSBQ uCO5f3o7MgRkvg8YW4R90S0qEAvBFfGmaU9A9valkJOyY+xXFpMgcjAf1/f0KcU9A/d2IJS0mgF x90uTmc1kwYqhYPiBFniM2P7rcPWbaPPnfv9ZhqECHXQATo2NFomGAEnY4hszvO3FQqIxe13mmJ 1tuJfm7+7Uuq2EUtkak/m2irTZCjpI/6tRYtF0ZKcqAzibZ7xWv2TqXBxZpAmoZg5emvHXBau1Y TR2O++8lPLLAQwAqiHwj4QyE7WZSf/0Deu3+M3I0lCBJjVN4jrlNfNEnwfTcXafSDhs3vRp8UR3 V3Bg0Cj6jdS5D5nz28NpBY8q6lpS+eBoo= X-Google-Smtp-Source: AGHT+IHrTqKKYJCiBiML2eFT7RgCdydzmIoMHhN3qe+XAG1Vm3jbl7fTxV/eF5kZguSF9odRaHq6Yg== X-Received: by 2002:a05:6e02:1a89:b0:42e:72ee:cde6 with SMTP id e9e14a558f8ab-42f8736aa0bmr133211865ab.12.1760117475263; Fri, 10 Oct 2025 10:31:15 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-58f7328a26csm1066459173.67.2025.10.10.10.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 10:31:14 -0700 (PDT) Date: Fri, 10 Oct 2025 12:31:13 -0500 From: Nathan Bossart To: David Rowley Cc: Jeremy Schneider , Sami Imseih , pgsql-hackers@postgresql.org Subject: Re: another autovacuum scheduling thread Message-ID: References: <20251008164057.6bceb9ed@ardentperf.com> <20251008172727.3befd129@ardentperf.com> <20251008182520.6e05a8b8@ardentperf.com> <20251008184740.328d45de@ardentperf.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DM8fxteXoufrDV0I" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --DM8fxteXoufrDV0I Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 09, 2025 at 11:13:48AM -0500, Nathan Bossart wrote: > On Thu, Oct 09, 2025 at 04:13:23PM +1300, David Rowley wrote: >> I think the best way to understand it is if you look at >> relation_needs_vacanalyze() and see how it calculates boolean values >> for boolean output params. So, instead of calculating just a boolean >> value it instead calculates a float4 where < 1.0 means don't do the >> operation and anything >= 1.0 means do the operation. For example, >> let's say a table has 600 dead rows and the scale factor and threshold >> settings mean that autovacuum will trigger at 200 (3 times more dead >> tuples than the trigger point). That would result in the value of 3.0 >> (600 / 200). The priority for relfrozenxid portion is basically >> age(relfrozenxid) / autovacuum_freeze_max_age (plus need to account >> for mxid by doing the same for that and taking the maximum of each >> value). For each of those component "scores", the priority for >> autovacuum would be the maximum of each of those. >> >> Effectively, it's a method of aligning the different units of measure, >> transactions or tuples into a single value which is calculated based >> on the very same values that we use today to trigger autovacuums. > > I like the idea of a "score" approach, but I'm worried that we'll never > come to an agreement on the formula to use. Perhaps we'd have more luck > getting consensus on a multifaceted strategy if we kept it brutally simple. > IMHO it's worth a try... Here's a prototype of a "score" approach. Two notes: * I've given special priority to anti-wraparound vacuums. I think this is important to avoid focusing too much on bloat when wraparound is imminent. In any case, we need a separate wraparound score in case autovacuum is disabled. * I didn't include the analyze threshold in the score because it doesn't apply to TOAST tables, and therefore would artificially lower their prioritiy. Perhaps there is another way to deal with this. This is very much just a prototype of the basic idea. As-is, I think it'll favor processing tables with lots of bloat unless we're in an anti-wraparound scenario. Maybe that's okay. I'm not sure how scientific we want to be about all of this, but I do intend to try some long-running tests. -- nathan --DM8fxteXoufrDV0I Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0001-autovacuum-scheduling-improvements.patch