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 1w0AgH-001g7U-20 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 03:56:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0AgF-007Oof-2L for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 03:56:20 +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.96) (envelope-from ) id 1w0AgF-007OoX-1J for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 03:56:19 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0AgD-000000024fK-2cdx for pgsql-hackers@postgresql.org; Wed, 11 Mar 2026 03:56:19 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-660dcafc85aso13059021a12.0 for ; Tue, 10 Mar 2026 20:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773201376; cv=none; d=google.com; s=arc-20240605; b=jCzVP9YyI9NmnbnacKRYfPU4jUMshOgE1LCwgOjhBBdxji1rz3mEjYbtng1nUIlREq HuO9spWBloPZHDbWzVpAQwY92xA+7jj7nHYBZks7khpBRhpUgJNej/8XweDHSNsPjyM6 SydgGjF0GpSP5BsEXptKBgu3V2FviQWtbeArJvR1cNTpiJg6Re0uIBIXBpOtDUV6FFuc GiOC+S1WwdxkS/q94jmCyDge3tlA/BGcK5zTyT0xEzCOyUtQOybIB1Dsndo9v9FBs1Sr +pxs61JuWvrqdIeOApui1l8u6lEF/VCi3VAPqyG2vMSPqC3Br02fchR80j24Lbf2WzGy W7tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=918kg2s6d/DbO+EQO6W7eejkoXcmnwWTAld6RcDOmHc=; fh=3CYUvw00rlaswfqQhzKLvlGexLSRcwK0HSj0ow8njB0=; b=QSK5zfTLA+/1b4lhyN6Yi/OKKiIsf3XnxT8d4bvKa//pCbCjjv4Fm/e2ftpDBdOkxk rALXkScYgfuEYRBVtNbQWyUK+VgKLBIQsJHf1nBLRwKzm5NkqW0N+O09hUq7Oehz/OfS GtgtqbGdMzMY7ODe4VR7Xy2AtxCTkCAT+uNlm3ejdjRpgMzCNTZkE9CtuZGgMv4I3lJV 2U4sCTFrEdfkP6BCcNoscduJYsl5A5i7j8e3y+EB/Ph3O8sFcQrgclbknVXxvh3f4fUA Ixv6pL2uXRKCNQYygdtrGvVf3f/+4a0Q6RPvpkacYd/+k1yA2KOnp7JpZnvnEh4vWTs2 oA9A==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773201375; x=1773806175; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=918kg2s6d/DbO+EQO6W7eejkoXcmnwWTAld6RcDOmHc=; b=exFBXuHY3ZeAD6rqZMokY2v/uKXhA6r6m4ZRkvSo0gM0Hgx7BrO6YBcXeHPAdAhn3Z P7IPLDweg8H8uSx8fXWQScFGAE3zlFwRYhrcv6slAGFz5uBN5dlFlUWYbATsqGITf9CI Wv+fwx7oGH5dn4IzIWtCNpFPmJseypscuWswjGzBgqbAoWHWlQLnl8y+tuEM6YaB1ouY jvkQA0EBySJSDaxgPAqTcC3VI8yhKchVhedoRDHYbVbE3DHVM3Eab4aWuzkTnshhR+42 t8y07PeqIIrId1pmsRsRBt4H+UxtfxOSxxYFAVATdyM3MP+wDEVN5dyUUxIIY3UfjMFB HuGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773201376; x=1773806176; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=918kg2s6d/DbO+EQO6W7eejkoXcmnwWTAld6RcDOmHc=; b=d40bDRKtvCTlz52HNtbSokqXP2LBOaOAQDxo3JIM24GIZlvdjk19E45iC3JeAbC5I3 h85jObakhg+tOeqCP6B8k3ggm9kfqprmEZ6+7TQ8aHSySdP9qMeOppW4wf5xGBtQQ0S3 +nGyIRb2uk9OLyexqcjJynoVA5rd7K99yIDAFlFQwCXjkTYKup7XwIIO1ceqyfSSZe41 CPRX819MHzJqOG12kj58X41BlUbJzMf05woXsUal8f+CUekXpXhwkgNpFKY0nbERLVMK RoFO5rDalSEPvKRI7brjlWoGi4xPDpk8t1p68Gw/qDqscrGWfdI3OLcdZ7KEB1Yipn2a iNJQ== X-Forwarded-Encrypted: i=1; AJvYcCWEwkXi9vuqjiGdHG5/tlSaZXtJd74GZeo+r7Bbz0RFzKDOoQ1tAh8VlbZjg8NTiyWA7SagJwqSBJ5p8QGO@postgresql.org X-Gm-Message-State: AOJu0Yx2kd7J/2h4gCymUWUlX4GvbT39hN3kAvXXLsHuNd1pOkePv3Gf krocgVUtZfafsLTF8/Msrvfcshzwqhc7MybQNAL4BY8SmEa6mP3T0ABiwaDNY86NrB99nhVfMKr 23yCvA4A+CcVjanCQChRkDfxTgR/vMIM= X-Gm-Gg: ATEYQzwwpzEjqZNOhDQaMhH6FRO77STeBY/3zceltZ2rGV+GDMgMGmX5y0pekRsKCr8 2xsYfAfnWlsSzz9EAj+zZL3utL4YQapifa4wca2+7KhNmkT6nGh1CA5E+tfZ0FqeC2gWa6Rb0f+ QQutxRXZiqfKhtXxbNFD7vTutJPYmDC3u8CdP9wEPcV2pvzstDl9UecvouRIBi3VBV6D7s7/0Be ac75mCMp3vg9NhcNBAIChZlNhAMdkw+eZvrPnE/1w1oL1Fk09yTUAHsHkZ0ki6doA51wOqP3fYR ay0//kPjybuzFZTMDd1eWYscj93wg3DEWxqJJQ== X-Received: by 2002:a17:907:a4c:b0:b96:e0b1:cd01 with SMTP id a640c23a62f3a-b972e5c793emr35677766b.39.1773201375377; Tue, 10 Mar 2026 20:56:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: wenhui qiu Date: Wed, 11 Mar 2026 11:56:04 +0800 X-Gm-Features: AaiRm52oJ1pZgklzLnRjQNPcNZDQ0LoMd3D6hYXL7O4AHdId5jLd-tFe7UkZe2o Message-ID: Subject: Re: another autovacuum scheduling thread To: Sami Imseih Cc: Nathan Bossart , Robert Haas , David Rowley , Robert Treat , Jeremy Schneider , pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="000000000000183b55064cb79e96" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000183b55064cb79e96 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable HI Sami > Do you think it will be better to just to add the age to the > score? > > if (xid_age >=3D effective_xid_failsafe_age) > xid_score +=3D (double) xid_age; > if (mxid_age >=3D effective_mxid_failsafe_age) > mxid_score +=3D (double) mxid_age > > For most cases, this should be high enough to to make the > score high enough to sort to the top, as mentioned in the > comments: Agree, +1.The calculation resulted in a very large number. I previously suggested modifying the algorithm like this: effective_xid_failsafe_age =3D (vacuum_failsafe_age + autovacuum_freeze_max_age) / 2.0. Typically, the `vacuum_failsafe_age` parameter is rarely adjusted by DBAs.My view has always been that tables whose age cannot be reduced should be prioritized, while we should try to avoid tables whose age is already close to vacuum_failsafe_age. Thanks On Wed, Mar 11, 2026 at 9:08=E2=80=AFAM Sami Imseih w= rote: > > Just a few things: > > > > 1/ > > + Oid xid_age; > > + Oid mxid_age; > > > > Is using Oid here intentional? I'm curious why not use uint32 for > clarity? > > > > 2/ > > The new GUC docs says "...component of the score...", but without > > introducing the concept of the prioritization score. > > I think we should expand a bit more on this topic to help a user > > understand and tune these more effectively. Attached is my > > proposal for the docs. I tried to keep it informative without > > being too verbose, and avoided making specific recommendations. > > My apologies. I found something else that may need > addressing. > > + if (xid_age >=3D effective_xid_failsafe_age) > + xid_score =3D pow(xid_score, Max(1.0, (double) > xid_age / 100000000)); > + if (mxid_age >=3D effective_mxid_failsafe_age) > + mxid_score =3D pow(mxid_score, Max(1.0, (double) > mxid_age / 100000000)); > + > > The current scaling calculation for force_vacuum could lead to > exorbitantly high scores. > Using DEBUG3 and consume_xids_until(2000000000), notice how the score goe= s > from 7.93 to 661828682916018.125 once past failsafe age. > > 36), anl: 0 (threshold 97929), score: 7.930 > 2026-03-10 19:41:11.979 CDT [74007] DEBUG: foo: vac: 0 (threshold > 195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score: > 7.930 > 2026-03-10 19:41:32.062 CDT [74038] DEBUG: foo: vac: 0 (threshold > 195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score: > 661828682916018.125 > 2026-03-10 19:41:32.063 CDT [74038] DEBUG: foo: vac: 0 (threshold > 195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score: > 661828682916018.125 > 2026-03-10 19:41:51.961 CDT [74066] DEBUG: foo: vac: 0 (threshold > 195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score: > 26761249940789168.000 > > Do you think it will be better to just to add the age to the > score? > > if (xid_age >=3D effective_xid_failsafe_age) > xid_score +=3D (double) xid_age; > if (mxid_age >=3D effective_mxid_failsafe_age) > mxid_score +=3D (double) mxid_age > > For most cases, this should be high enough to to make the > score high enough to sort to the top, as mentioned in the > comments: > > + * As in vacuum_xid_failsafe_check(), the effective > failsafe age is no > + * less than 105% the value of the respective > *_freeze_max_age > + * parameter. Note that per-table settings could > result in a low > + * score even if the table surpasses the failsafe > settings. However, > + * this is a strange enough corner case that we don't > bother trying to > + * handle it. > + */ > > -- > Sami Imseih > Amazon Web Services (AWS) > > > --000000000000183b55064cb79e96 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
HI Sami
> Do you think it will be better to just to= add the age to the
> score?
>
> =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (xid_age >=3D effective_xid_failsaf= e_age)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0xid_score +=3D (double) xid_age;
> =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (mxid_age >=3D effective= _mxid_failsafe_age)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mxid_score +=3D (double) mxid_age
= >
> For most cases, this should be high enough to to make the
= > score high enough to sort to the top, as mentioned in the
> comm= ents:
Agree, +1.The calculation resulted in a very large numb= er.=C2=A0I previously suggested modifying the algorithm like this:
effective_xid_failsafe_age =3D (vacuum_failsafe_age + autovacuum_freeze_m= ax_age) / 2.0. Typically, the `vacuum_failsafe_age` parameter is rarely adj= usted by DBAs.My view has always been that tables whose age cannot be reduc= ed should be prioritized, while we should try to avoid tables whose age is = already close to vacuum_failsafe_age.




Thanks

<= br>
On Wed, Mar 11, 2026 at 9:08=E2=80=AFAM Sami Imseih <samimseih@gmail.com> wrote:
<= /div>
> Just a few things:
>
> 1/
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 Oid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 xid_age;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 Oid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 mxid_age;
>
> Is using Oid here intentional? I'm curious why not use uint32 for = clarity?
>
> 2/
> The new GUC docs says=C2=A0 "...component of the score...", = but without
> introducing the concept of the prioritization score.
> I think we should expand a bit more on this topic to help a user
> understand and tune these more effectively. Attached is my
> proposal for the docs. I tried to keep it informative without
> being too verbose, and avoided making specific recommendations.

My apologies. I found something else that may need
addressing.

+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (xid_age >=3D= effective_xid_failsafe_age)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0xid_score =3D pow(xid_score, Max(1.0, (double)
xid_age / 100000000));
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (mxid_age >= =3D effective_mxid_failsafe_age)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0mxid_score =3D pow(mxid_score, Max(1.0, (double)
mxid_age / 100000000));
+

The current scaling calculation for force_vacuum could lead to
exorbitantly high scores.
Using DEBUG3 and consume_xids_until(2000000000), notice how the score goes<= br> from 7.93 to 661828682916018.125 once past failsafe age.

36), anl: 0 (threshold 97929), score: 7.930
2026-03-10 19:41:11.979 CDT [74007] DEBUG:=C2=A0 foo: vac: 0 (threshold
195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score:
7.930
2026-03-10 19:41:32.062 CDT [74038] DEBUG:=C2=A0 foo: vac: 0 (threshold
195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score:
661828682916018.125
2026-03-10 19:41:32.063 CDT [74038] DEBUG:=C2=A0 foo: vac: 0 (threshold
195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score:
661828682916018.125
2026-03-10 19:41:51.961 CDT [74066] DEBUG:=C2=A0 foo: vac: 0 (threshold
195809), ins: 0 (threshold 176836), anl: 0 (threshold 97929), score:
26761249940789168.000

Do you think it will be better to just to add the age to the
score?

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (xid_age >=3D = effective_xid_failsafe_age)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0xid_score +=3D (double) xid_age;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (mxid_age >=3D= effective_mxid_failsafe_age)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0mxid_score +=3D (double) mxid_age

For most cases, this should be high enough to to make the
score high enough to sort to the top, as mentioned in the
comments:

+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * As in vacuum_xid= _failsafe_check(), the effective
failsafe age is no
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * less than 105% t= he value of the respective *_freeze_max_age
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * parameter.=C2=A0= Note that per-table settings could
result in a low
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * score even if th= e table surpasses the failsafe
settings.=C2=A0 However,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * this is a strang= e enough corner case that we don't
bother trying to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * handle it.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 */

--
Sami Imseih
Amazon Web Services (AWS)


--000000000000183b55064cb79e96--