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 1vDPjw-008Unh-Se for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Oct 2025 16:06:36 +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 1vDPjv-008E8n-LY for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Oct 2025 16:06:34 +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 1vDPjv-008E8e-3L for pgsql-hackers@lists.postgresql.org; Mon, 27 Oct 2025 16:06:34 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vDPjr-0043M7-1e for pgsql-hackers@postgresql.org; Mon, 27 Oct 2025 16:06:32 +0000 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-9435969137aso257464839f.1 for ; Mon, 27 Oct 2025 09:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761581191; x=1762185991; 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=Posl1HgNprvz33qa66FUQd4uHQlztclc60C0zzMszKY=; b=aqbc9uUsEgn5gUVRgH5DRk2Vx7at3bypZeRqqpUPt0uDrhk3me0hGZPGPxno2ZAu57 GMiCDp8YLET3d/EejKg56ljV4QVLW1ntmAiqIjNiUbWSVi5XinTFrqhrTqlseLrCU9LK qsuBhvCXlUonMNqEboVclADCbuSim69TVOBr/KTrj6s9koz5DXNYO9/g/GHcKZfiw2T7 REA5pif/u6ftIhwtMJeYNUVXoAG/fxrnc6TRlSxHbKAoX/38WC50ah3D0zci0UFouEub huGV76MeWmFc3PJbtEqoTfAMiDn1n9BqzKB89tFikIjYTDFjfn+LVnjH4R2wqCIZ2Egy 0W0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761581191; x=1762185991; 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=Posl1HgNprvz33qa66FUQd4uHQlztclc60C0zzMszKY=; b=AyOJtpGpgK0RK7YeIHnj0roEUWWlGCNN7kPmSk7LT9JgRcQyLXdE2bnaMn2oHi05jX ZwL6pbtbXV3bMl5jLX+9Qs6Gd9tCH/UN1n7ImwrLSZImhi+pJdz+z3tAT0MqZWXqd2ff 4L93ttYp8Km6Hf1ywZobWW0JhKp/N96cKB5sC2G7wPDPqNEVj9A6YD+TB5Cb22VehVFs NIhbdhKHKqhLgXLhFQOMhjRh/xpI9mRLo50mIPCA+xsZOBG0E18Jmk8xaYJW1INY/T/7 xoY+kU79fN5esGYY63bQj8Wiz67lvXgYAPGRJIjjx+LplgNxG+SPu+o57v2mV82/wgWv bh0w== X-Forwarded-Encrypted: i=1; AJvYcCUFlKzux5Pi/seFLrETnj919tRf46RMCqMTj7wBME/1/7EjF4nEuFitLsZlPsrjSQGs5DRwU5FQevZZEusj@postgresql.org X-Gm-Message-State: AOJu0YxswKftwHYhU0MPYrmxT5bfksgiBp2XIKJzMVy0jtN6sJOPMWGw UeKnKDx9n2oqrUzDoZbpoJJOyEra2u6zSlPmwbNydVBi/L92giar6sMG X-Gm-Gg: ASbGncvwwPPYvI78fIbwlAwCxRVq+mVOrRhEmpMmnocqzQbLqHzMvtC0NIyNlXvTHKy 6aOVVf7s53wMCtA2T/RoIm8pICt7aDhHVF49aNNf8DKYiyIqIkhfOi8YkioQE72n8d02TqKcmI7 nEgLT1ZAgQku2EtbEP9gMMOfAOiOmhuZx51QHCAgIT564KHCo60wRCrAUbycnEgNXtu+zQO9h/4 znRpNyHboogAna40NRWTuOZW5Mg1wb/mZl3Y0co4Ztw4HyoJxQg8bY9kzDUAH+klUxjnAQT8FfO 2f7tqLhEUcCXXRYtmSik8+5SW6WyYg/UbwoF/f7nv6Kk5e6ZsyP6SO0K4uxsosSgVnaU3LUFHT1 fwzNpcD6YrS+wKAgIv4JaUUeWZhT/4C0pItVOjr5LhL4Q5OJB9ub+Unky62/iuIpOUQk6YOe4ys qzSpBAR4f7LvRBPnjeg74QwznqVcoOJbnXlke8AWcNxI6aZjtAmIaOB0+MxMLeOMhEzw== X-Google-Smtp-Source: AGHT+IGBG225hkKDDyD8BjZe+//H+BSF17xb5f/JNvT86xTW+kEvRzTSDxPgTAiA806U7Av40s/o8Q== X-Received: by 2002:a05:6602:6016:b0:93e:8332:208e with SMTP id ca18e2360f4ac-945b80210c8mr101880539f.5.1761581189224; Mon, 27 Oct 2025 09:06:29 -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-5aea7ce6eefsm3229967173.28.2025.10.27.09.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Oct 2025 09:06:28 -0700 (PDT) Date: Mon, 27 Oct 2025 11:06:26 -0500 From: Nathan Bossart To: David Rowley Cc: Sami Imseih , Robert Haas , Jeremy Schneider , pgsql-hackers@postgresql.org Subject: Re: another autovacuum scheduling thread Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3WukBUceFvEOzYGw" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3WukBUceFvEOzYGw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Oct 26, 2025 at 02:25:48PM +1300, David Rowley wrote: > Thanks. I've just had a look at it. A few comments and questions. Thanks. > 1) The subtraction here looks back to front: > > + xid_age = TransactionIdIsNormal(relfrozenxid) ? relfrozenxid - recentXid : 0; > + mxid_age = MultiXactIdIsValid(relminmxid) ? relminmxid - recentMulti : 0; D'oh. > 2) Would it be better to move all the code that sets the xid_score and > mxid_score to under an "if (force_vacuum)"? Those two variables could > be declared in there too. Seems reasonable. > 3) Could the following be refactored a bit so we only check the "relid > != StatisticRelationId" condition once? Yes. We can update the vacuum part to follow the same pattern, too. > 4) Should these be TransactionIds? > > + uint32 xid_age; > + uint32 mxid_age; Probably. > 5) Instead of: > > + double score = 0.0; > > Is it better to zero the score inside relation_needs_vacanalyze() so > it works the same as the other output parameters? My only concern about this is that some compilers might complain about potentially-uninitialized uses. But we can still zero it in the function regardless. -- nathan --3WukBUceFvEOzYGw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0001-autovacuum-scheduling-improvements.patch