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 1v6Y6X-006IKs-2U for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Oct 2025 17:37:33 +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 1v6Y6U-00ByLs-It for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Oct 2025 17:37:31 +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 1v6Y6U-00ByLj-96 for pgsql-hackers@lists.postgresql.org; Wed, 08 Oct 2025 17:37:31 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v6Y6N-000hvF-2f for pgsql-hackers@postgresql.org; Wed, 08 Oct 2025 17:37:30 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 456051D0007A; Wed, 8 Oct 2025 13:37:24 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 08 Oct 2025 13:37:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1759945044; x=1760031444; bh=vUt/r405jh IFV2+Mm/XHo06zwOi7e6OHtJA2+xMTkXE=; b=S6Hj+0SAUuxhRNuMxiyB+XtkUN zilAPbmm8xKfflxtOW1vQHsWXl+y1q2C63eJpGTzRATFO3ByefuVy25KU08IXnn2 aNBvLOKmDQ7qtPgjOwgrKOfoBmOfSczqpXrWNvudHkoyJ5ciOGlsVCF1VYoTFoMl sfn6qohfqU0ZDA6V3sWazL/j2RIgnG3o45OSpiHtbWxx/l+0Ada7cDCgY8ktMZu8 NfaB/2bXyzmqR6kaiEuHFQbB5Effbw92fZG5J1Is57ZSuhmeuZqb9OGxTyN2au0z eX181w6MMA0yjtKMSmoXG3N+NDMRirZHRFfJup65sr8l/mIUgMYquic1+Pgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1759945044; x=1760031444; bh=vUt/r405jhIFV2+Mm/XHo06zwOi7e6OHtJA 2+xMTkXE=; b=COAQTMg69rcWRJccJspdA1z+eUGsMX5PNroQqQIKpouuAKqZQ5s M2DoRmk1IziX93q/xT67iixGLGIheeCKS6Oc9JXXhzomXaZ9POIGzEHq7qfGHxtp YizGVFdbQRrDXJk+cDKYoF+cKQGsK7FeYSm5MnRkTsCZGYIfHWe35lFwc2xKfF5G dB1W/D1u6JdoMtHxQYb9FqMk3zGcbWAy9r2NLCWsy36upgqo/0bM3DrWCj0i5Aql ABNeOfVq4tkDYqHvg8C98OzmICe8FS88daOBtQUH/7n+dg8sjlDiNLh/XqZLBsRD 3KhaGUT1pJoumN4mJnBQ8/hTgSwbhU1nfsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddutdefledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefh ueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopedvpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehnrghthhgrnhgusghoshhsrghrthesghhmrghilh drtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhq lhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Oct 2025 13:37:23 -0400 (EDT) Date: Wed, 8 Oct 2025 13:37:22 -0400 From: Andres Freund To: Nathan Bossart Cc: 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 Hi, On 2025-10-08 10:18:17 -0500, Nathan Bossart wrote: > However, we do no such prioritization of the tables within a database. In > fact, the ordering of the tables is effectively random. We don't prioritize tables, but I don't think the order really is random? Isn't it basically in the order in which the data is in pg_class? That typically won't change from one autovacuum pass to the next... > * Prioritizing tables based on their (M)XID age might help avoid more > aggressive vacuums, not to mention wraparound. Of course, there are > scenarios where this doesn't work. For example, the age of a table may > have changed greatly between the time we recorded it and the time we > process it. > Or maybe there is another table in a different database that > is more important from a wraparound perspective. That seems like something no ordering within a single AV worker can address. I think it's fine to just define that to be out of scope. > We could complicate the patch to try to handle some of these things, but I > maintain that even some basic, incremental scheduling improvements would be > better than the status quo. And we can always change it further in the > future to handle these problems and to consider other things like bloat. Agreed! It doesn't take much to be better at scheduling than "order in pg_class". > The attached patch works by storing the maximum of the XID age and the MXID > age in the list with the OIDs and sorting it prior to processing. I think it may be worth trying to avoid reliably using the same order - otherwise e.g. a corrupt index on the first scheduled table can cause autovacuum to reliably fail on the same relation, never allowing it to progress past that point. Greetings, Andres Freund