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 1tVFHt-006iwO-H9 for pgsql-performance@arkaria.postgresql.org; Tue, 07 Jan 2025 19:30:50 +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 1tVFHs-0070qh-Oz for pgsql-performance@arkaria.postgresql.org; Tue, 07 Jan 2025 19:30:48 +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 1tVFHs-0070qZ-BK for pgsql-performance@lists.postgresql.org; Tue, 07 Jan 2025 19:30:48 +0000 Received: from mail-vk1-xa35.google.com ([2607:f8b0:4864:20::a35]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tVFHp-000Nd8-2q for pgsql-performance@lists.postgresql.org; Tue, 07 Jan 2025 19:30:47 +0000 Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-5189a440a65so9207995e0c.1 for ; Tue, 07 Jan 2025 11:30:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736278245; x=1736883045; darn=lists.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=w9+ftlDE8kzSpLuwOwTVLSYTPa+wzrsuYggqhKDe4+8=; b=ElxzxLSAowTIKQc4EK5hEBr0w2I+ldUA9AlPfvhhxzKxK+KC95hiWlkem1FlqmWpre CLHlMdBG+PuLwvzl4tQMo+YZUkbDluio7K5axWqBc9og9pbSC0JlOByEAWz9fcX7sFxR n1sk1JhvV6gUMhTSrOJYRGgmo+xYtqYGOs9pniinE9KOtVJBYrBu3tbaZOTBRob2/MGg uVbLj5nrJdPUrvcnntlPUbmmja7udUYzV3PjY9Ls6tNvjH30Wmb+gfVKclimttbDdp7r jnZm95+yQ/XraBXKvw6dBWanKcerZkJdUJAAQQbPh636Cmf6wLaOJneE6vln+RKMbid0 3jkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736278245; x=1736883045; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w9+ftlDE8kzSpLuwOwTVLSYTPa+wzrsuYggqhKDe4+8=; b=mVJcq4ArHrdCbPFiHBuTpHj8iRmVumIhazGda7XzPQnJcfupZjSmbRK6yYQYa2+KT0 ByMN6qtNPe0ozO+fLfY8YuKKXznQw2ZyHTcIa80sPm+hegsQOZc94c5wcXq46p5hvBdR IX2UkjtZwRK/Ca5fCUXIn9ZQzmP+0O+gd0V0ACd1SDOFZ4srSOnypxeXtJwRoiZKM0oE SREl08Br7uHtwaLFe5W6jk4hMmi2ybMe0kJuxfv5kgtP6bX00+SMXOS4gowffVW0Qw7M /6a9rujovmcI+WOn3bGNelTYC3oI41f+d3W1xt4K3RzJQIFleQvk4dAVv9+I26mWrRvC m0+Q== X-Gm-Message-State: AOJu0YyUhJ+FJ8TxIYTR7ZONR1fG7bmSnNWE7dPCO1hx9EPCC+uA1AaF xa6moAm8WCMUVn0ewUk2wEfTph6cJtFkOBkazAR76H+agZ6JrE4QFabO9a72rYDFsvIj74iJ6CN T5qJsnmyDNF5yvMvkZ348gCB+WA== X-Gm-Gg: ASbGncv2vonhkRUHBHsZEgNd9VoK6qcqebdZTN70uguJEvybSACJ6MPR77+DPOh8uNW FzabGhKqQGz3jY+ImuYdeBf94oMdr4TyNOF0YnaJKvTqwUv2L817asrCM6/yoGs7OL8IBmQ== X-Google-Smtp-Source: AGHT+IFw5c9OdAMWB951UJ7duJxiFZaOCz+hd6odxM7flrC2ifKYAGfa5isWbXD9cdw7yhoTODwH15kx1lXuZSk8ntE= X-Received: by 2002:a05:6102:2925:b0:4b2:5c4b:55e9 with SMTP id ada2fe7eead31-4b3d0d7727amr533971137.3.1736278245018; Tue, 07 Jan 2025 11:30:45 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jeff Janes Date: Tue, 7 Jan 2025 14:30:33 -0500 X-Gm-Features: AbW1kvaRiNBaUe370PF1316Yu8X5RSqIHwzK1mIgjkNOOjN-xQ9jSVnTPhH2vug Message-ID: Subject: Re: Aggressive vacuum To: Graham Hay Cc: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000000693cc062b22c877" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000693cc062b22c877 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 19, 2024 at 8:37=E2=80=AFAM Graham Hay w= rote: > > > > https://www.postgresql.org/docs/15/routine-vacuuming.html#VACUUM-FOR-WRAP= AROUND > > This link is to v15 docs. Is that the version you are actually using? The behavior of this feature has changed (repeatedly) over the years, so this is important to know. > This was definitely an improvement, but > when the big vacuum (freeze) kicked off there was a noticeable > io/latency spike. Was the change noticeable because it caused degradation in the user experience (latency of things users actually care about) or because you have monitoring tools which detected a change even though no one was complaining? Can you tell if the cause is driven by sequential reads, random reads, or writes? The way to suppress IO spikes is generally to tweak the vacuum_cost_* and/or auto_vacuum_vacuum_cost_* settings. This will make the vacuums take longer but be less intensive. > We then tried setting: > > - autovacuum_freeze_table_age=3D100000000 # 100M > > which seemed to make it happen more frequently (and one would hope, > with less work to do). We reduced this to 50M, and again it was more > frequent (but not the 2x I expected). And when I dropped it to 10M, > nothing changed. > Please be more quantitative. It wasn't 2x, but then what was it? And how long did each one take? Freezing automatically more often is likely not the answer to IO spikes. Going from gumming up your system once a week for one hour to gumming it up 3 times a week for 20 minutes each is likely not a real solution. And it might not even do that--you could gum it up 3 times a week for 50 minutes each! Unless you have large swaths of table which become effectively read-only over time, each aggressive vacuum might need to do the same amount of IO so doing it more often just makes things worse. The solution would be to either use the *vacuum_cost_* parameters to throttle it down to the point where it doesn't cause problems, or intentionally schedule vacuum freeze during quiet periods (over night, over weekends) preempting the need for them to happen automatically. Cheers, Jeff --0000000000000693cc062b22c877 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Dec 19, 2024 at 8:37=E2=80=AFAM G= raham Hay <grahamrhay@gmail.com<= /a>> wrote:


https://www.postgresq= l.org/docs/15/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND


This link is to v15 docs.=C2=A0 Is tha= t the version you are actually using?=C2=A0 The behavior of this feature ha= s changed (repeatedly) over the years, so this is important to know.
<= div>=C2=A0
=C2=A0Thi= s was definitely an improvement, but
when the big vacuum (freeze) kicked off there was a noticeable
io/latency spike.

Was the change noticeabl= e=C2=A0because it caused degradation in the user experience (latency of thi= ngs users actually care about) or because you have monitoring tools which d= etected a change even though no one was complaining?=C2=A0 Can you tell if = the cause is driven by sequential reads, random reads, or writes?

The way to=C2=A0 suppress IO spikes is generally to tweak t= he vacuum_cost_* and/or=C2=A0auto_vacuum_vacuum_cost_* settings.=C2=A0 This= will make the vacuums take longer but be less intensive.
=C2=A0<= /div>
We then tried settin= g:

=C2=A0 =C2=A0 =C2=A0 - autovacuum_freeze_table_age=3D100000000 # 100M

which seemed to make it happen more frequently (and one would hope,
with less work to do). We reduced this to 50M, and again it was more
frequent (but not the 2x I expected). And when I dropped it to 10M,
nothing changed.

Please be more quantit= ative.=C2=A0 It wasn't 2x, but then what was it?=C2=A0 And how long=C2= =A0did each one take?

Freezing automatically more = often is likely not the answer to IO spikes.=C2=A0 Going from gumming up yo= ur system once a week for one hour to gumming it up 3 times a week for 20 m= inutes each is likely not a real solution.=C2=A0 And it might not even do t= hat--you could gum it up 3 times a week for 50 minutes each! Unless you hav= e large swaths of table which become effectively read-only over time, each = aggressive vacuum might need to do the same amount of IO so doing it more o= ften just makes things worse.

The solution would b= e to either use the *vacuum_cost_* parameters to throttle it down to the po= int where it doesn't cause problems, or intentionally schedule vacuum f= reeze during quiet periods (over night, over weekends) preempting the need = for them to happen automatically.
=C2=A0
Cheers,
<= div>
Jeff
--0000000000000693cc062b22c877--