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 1v1Z09-00A06j-GQ for pgsql-general@arkaria.postgresql.org; Wed, 24 Sep 2025 23:34: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 1v1Z07-00GSqI-1U for pgsql-general@arkaria.postgresql.org; Wed, 24 Sep 2025 23:34:19 +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.94.2) (envelope-from ) id 1v1Z06-00GSpr-Mc for pgsql-general@lists.postgresql.org; Wed, 24 Sep 2025 23:34:18 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v1Z02-002i5E-2X for pgsql-general@postgresql.org; Wed, 24 Sep 2025 23:34:18 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-621a79a580bso113272eaf.2 for ; Wed, 24 Sep 2025 16:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758756854; x=1759361654; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=fKqZOakVOB6rtJtb2zu1XeMWaZQqTMh2ch2/wYXJI+Y=; b=dPfT7RrU+CcPMN1X+7s2aWpt7057AWihi2bJ8oyODSA/AQTEnXG1IzFHXWaBEFAGc4 3xPAu1wwxfK2GyA8G+PaD6zUB9R9kkzUzfuOy+HE260Ypluda3O0qEVnotMJ/ZicVEPP 09dCg3aAm5CyWozRww9MuYj4UTzBReoTQGsYRLhyW9tl/poTjZImvcCSWU+JlyghBlYU 70b7zj7xDPadLy1A3ZP02GiLi79xcKujrvZfSWnNCcjUXDESaxHGqNF5Jdg01W2jEku9 6FfY/V2Y4Q0704Xts20tMlQb0SkwiFHcaxHDfSCy386y2506m4hUTBM4JiWHDohdfry9 +j5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758756854; x=1759361654; h=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=fKqZOakVOB6rtJtb2zu1XeMWaZQqTMh2ch2/wYXJI+Y=; b=HjV/on1sbiRUQGSzM+s82huyoGHvGbT87ciwLzOuJa7Uom0du6nOnU9IBeUVmKw7ue V5XnKdVTXLPH6NHL9Ick6J9JkpqqwKR+zUSKlkk66GRDrbh2xXjWRHpoR+Z+kRPcefbx 6JNS+gXKMX+ITuRpqCwGCUOn2kwNLkhHegx+ulwJVGoYm7cHXU0GdZ4mzfduqFNX1XfG +pj9kPd3CrISWxh0s4/eSs6h6LVZxhUQ2P0CHm/F96svZHK/vnBhVSE3qAjKW5gpkigi BVQy5dYa8rZ3XNM36deTHxvr8BAvbXF4VRqd2ldHtgsqXD3TMh93pijOdzFO27Omzdzp PSXw== X-Gm-Message-State: AOJu0Yy52VS8L6/qFtDP6h/8bul2FQt+TPgWs3XrXHwWCuVz7i+dKuV6 EyNtXSR549+FFYwz0jTAF1oRMS8NFcLnIlEGY1URARHYlsmyuUv1aMlxlwVNDTUmlCKaeZP6mcP r1FD3FzoeuzYh/XcqbrKBVsffQXCt4LF1GHNs X-Gm-Gg: ASbGncsIHwaglNfN7O6a8QnRIdcznK0CYbdGtfiuEiSNw401H48GgeALDsrb0DojtNb IrV1cRYkX/vE/crBvLgp9ono9TcigmSLHL/VDlVfBP6ZQvLQDzYOSfAH8GcAq4yQoeW7beOJR/W TTwAvPU/EXjnYy0UKvNs8W4haZLu/6ZYxOxZgz2G9wSN8U8HgTAoKnhZsjId5bwX+WBqRp9+tts 45jFJLE X-Google-Smtp-Source: AGHT+IG21lgrCTqs67oTO87mFQfuLRkwzBztZ8RgAYn9jOiZn28LaghDYnzMw7nKN9OkGLWE7edplEHEw8dqFG5ojHc= X-Received: by 2002:a05:6808:11d1:b0:43b:7b9b:a881 with SMTP id 5614622812f47-43f4ced1557mr939865b6e.43.1758756854154; Wed, 24 Sep 2025 16:34:14 -0700 (PDT) MIME-Version: 1.0 References: <8E8DB597-41BA-4E6F-A792-13B8AA9238D2@gmail.com> In-Reply-To: <8E8DB597-41BA-4E6F-A792-13B8AA9238D2@gmail.com> From: Ron Johnson Date: Wed, 24 Sep 2025 19:34:03 -0400 X-Gm-Features: AS18NWDJqoHrhpYdzGDRUzIv6t2JocvHeunb9iEiYkcly_am2Oz8h2TAnd24j2U Message-ID: Subject: Re: Index rebuilding strategy To: pgsql-general Content-Type: multipart/alternative; boundary="00000000000089cc69063f947dbf" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000089cc69063f947dbf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Sep 24, 2025 at 4:51=E2=80=AFPM Alban Hertroys = wrote: > > > On 24 Sep 2025, at 22:42, Siraj G wrote: > > > > Hello Experts! > > > > What are the top pointers we should consider for index rebuild? Check > its size, bloat estimate, heavy Updates/Deletes? > > > > Please highlight the best practices. > > I think just any pointers of corruption, really. OS updates with differin= g > collation implementations, known flaky hardware or driver issues, checksu= m > discrepancies if you have those turned on and get any of those. > > The need to rebuild indices should be quite rare. Regular vacuuming and > analysing should take care of most of the need, with much of those > happening automatically anyway (could need some tuning though). > I drop the scale factors down to 1.5% and the insert threshold to 500. The application we run seems to like that. YMMV, of course. autovacuum_analyze_scale_factor =3D 0.015 autovacuum_vacuum_scale_factor =3D 0.015 autovacuum_vacuum_insert_scale_factor =3D 0.015 autovacuum_vacuum_insert_threshold =3D 500 Also, I repack tables when abs(correlation) gets below 60% (which eventually happens on tables where the oldest records are regularly deleted). That rebuilds the indices for you. (Why don't I partition those tables? 1. It's a 3rd party application; thus, they control the schema. 2. Partitioning by date means adding a date field to the PK, which means the PK really isn't a PK anymore.) --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --00000000000089cc69063f947dbf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Sep 24, 2025 at 4:51=E2=80=AFPM A= lban Hertroys <haramrae@gmail.com<= /a>> wrote:

> On 24 Sep 2025, at 22:42, Siraj G <
tosiraj.g@gmail.com> wrote:
>
> Hello Experts!
>
> What are the top pointers we should consider for index rebuild? Check = its size,=C2=A0 bloat estimate, heavy Updates/Deletes?
>
> Please highlight the best practices.

I think just any pointers of corruption, really. OS updates with differing = collation implementations, known flaky hardware or driver issues, checksum = discrepancies if you have those turned on and get any of those.

The need to rebuild indices should be quite rare. Regular vacuuming and ana= lysing should take care of most of the need, with much of those happening a= utomatically anyway (could need some tuning though).
<= br>
I drop the scale factors down to 1.5% and th= e insert threshold to=C2=A0500.=C2=A0 The application we run seems to like = that.=C2=A0 YMMV, of course.

autovacuum_analyze_scale_factor =3D 0.015
autovacuum_vacuum_scale_fa= ctor =3D 0.015
autovacuum_vacuum_insert_scale_factor =3D 0.015
autovacuum_vacuum_insert_threshold =3D 500=

Also, I repack tables when abs(correlation= ) gets below 60% (which eventually happens on tables where the oldest recor= ds=C2=A0are regularly deleted).=C2=A0 That rebuilds the indices for you.

(Why don't I partition those tables?=C2=A0 1. It= 's a 3rd party application; thus, they control the schema. 2. Partition= ing by date means adding a date field to the PK, which means the PK really = isn't a PK anymore.)

--
Death to <Redacted>, and butter sauce.
Don't boil me= , I'm still alive.
<Redacted> lobster!
--00000000000089cc69063f947dbf--