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 1snm64-005x4T-Gn for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Sep 2024 21:38:57 +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 1snm63-001dVg-Vh for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Sep 2024 21:38:55 +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 1snm63-001dVX-MW for pgsql-hackers@lists.postgresql.org; Mon, 09 Sep 2024 21:38:55 +0000 Received: from mail-ua1-x929.google.com ([2607:f8b0:4864:20::929]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1snm5w-000MyA-6K for pgsql-hackers@lists.postgresql.org; Mon, 09 Sep 2024 21:38:55 +0000 Received: by mail-ua1-x929.google.com with SMTP id a1e0cc1a2514c-846ca104682so35055241.2 for ; Mon, 09 Sep 2024 14:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725917927; x=1726522727; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=URBgPz6RSYBA8bWuOuYA87eXqwe4+ClQjvQf6jiWmcU=; b=Wjs3bNa8P5pP1PwvIOftWjEAg6mom3dFpmf2mNIxf1aBBrVX1gMYi68Fp6Jh1j/8nh 4cQNwVy+4htrvjJJBc8fTX6mNapD1B8mb3j9HGsCN/qjmSifn5H2QWMsCWSCHYr+9oim H/NTjE+qkQK2v1CdWMT/ykYXPB/dAMxPCX5Gfc0ujeSBqS2SafBt7iW/ZArKqXzbyB32 BVLyIEazPnYQQnyy+ZWAub+IAm1MYoGGiAaeaMKNl+oLRHgQOL7K//PD7950LeRFlW1G YCoj8tP/0NW/5y2anw4v/lDxBbJFOY+5n7jncqYmqTfCK6ZtPguiOO2j3rQoUZ892j1t THZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725917927; x=1726522727; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=URBgPz6RSYBA8bWuOuYA87eXqwe4+ClQjvQf6jiWmcU=; b=hy/5vSaViD8tL3fjhJztdhqxX+3zQ+b4S3GJQ+Hyhx/pbDc19ynQQ2J6Q4lI/QVydf ccQmaOSbnMSpRknV3glhPOt8EEtxe1OJF7linzp837fUJVHtHdiKkWcuz1RdIk9Yfn2s octM2d+06yLEVanzRWLHXA1q9vpU0AGkQFc+/sW7/3aA9ORnH5juHoU7PjI3SVEDWG+v Mm0yemoutrYkFcV3jGiodOzs9nLUEhX9C2Aw5z89xwXSSgLad8fO3D40olCElTCe7fUj d3zfx7zsiv5ffCIjbuna44xenDsmcqQkUrEyzyuaoKZ1Txh0h2iIBJ6h2B66C5DAMzD2 I3OQ== X-Gm-Message-State: AOJu0Yy/iKMGXq3Lkmfhj6ZrM8epA2U3KbmI81H/T2i4WTWkv+ILN/4v uIb3I5FG95Pgrbfii6Z7LUM/g15tWEefF4wvODJyUN7ZkdLelA+lKJI8sgHcjOhUpFENwRym1Aj C2SVdV2BvASIZ4Xd/nv9QNDJs5Tof34rt X-Google-Smtp-Source: AGHT+IFaG7D6PP78dGFC1nhRh+UyL27GNv9gHEuobcwINXyYCYkitRoUhzu8V4mSi1rbyiM+VX4T2stKajOVdvIbPTk= X-Received: by 2002:a05:6102:f09:b0:48f:e954:2426 with SMTP id ada2fe7eead31-49beccbc8a0mr7097911137.2.1725917926862; Mon, 09 Sep 2024 14:38:46 -0700 (PDT) MIME-Version: 1.0 From: Shayon Mukherjee Date: Mon, 9 Sep 2024 17:38:35 -0400 Message-ID: Subject: Proposal to Enable/Disable Index using ALTER INDEX To: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000f1375e0621b694f4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f1375e0621b694f4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello hackers, This is my first time posting here, and I=E2=80=99d like to propose a new f= eature related to PostgreSQL indexes. If this idea resonates, I=E2=80=99d be happy= to follow up with a patch as well. *Problem*: Adding and removing indexes is a common operation in PostgreSQL. On larger databases, however, these operations can be resource-intensive. When evaluating the performance impact of one or more indexes, dropping them might not be ideal since as a user you may want a quicker way to test their effects without fully committing to removing & adding them back again. Which can be a time taking operation on larger tables. *Proposal*: I propose adding an ALTER INDEX command that allows for enabling or disabling an index globally. This could look something like: ALTER INDEX index_name ENABLE; ALTER INDEX index_name DISABLE; A disabled index would still receive updates and enforce constraints as usual but would not be used for queries. This allows users to assess whether an index impacts query performance before deciding to drop it entirely. *Implementation*: To keep this simple, I suggest toggling the indisvalid flag in pg_index during the enable/disable operation. *Additional Considerations*: - Keeping the index up-to-date while it=E2=80=99s disabled seems preferable= , as it avoids the need to rebuild the index if it=E2=80=99s re-enabled later. The alternative would be dropping and rebuilding the index upon re-enabling, which I believe would introduce additional overhead in terms of application logic & complexity. - I am also proposing to reuse the existing indisvalid flag to avoid adding new state and the maintenance that comes with it, but I=E2=80=99m open to f= eedback if this approach has potential downsides. - To keep the scope minimal for now, I propose that we only allow enabling and disabling indexes globally, and not locally, by supporting it exclusively in ALTER INDEX. I would love to know if this would break any SQL grammar promises that I might be unaware of. I would love to learn if this sounds like a good idea and how it can be improved further. Accordingly, as a next step I would be very happy to propose a patch as well. Best regards, Shayon Mukherjee --000000000000f1375e0621b694f4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello hackers,

This is my first time posting here, = and I=E2=80=99d like to propose a new feature related to PostgreSQL indexes= . If this idea resonates, I=E2=80=99d be happy to follow up with a patch as= well.

Problem:
Adding and removing indexes is a common op= eration in PostgreSQL. On larger databases, however, these operations can b= e resource-intensive. When evaluating the performance impact of one or more= indexes, dropping them might not be ideal since as a user you may want a q= uicker way to test their effects without fully committing to removing &= adding them back again. Which can be a time taking operation on larger tab= les.

Proposal:
I propose adding an ALTER INDEX command tha= t allows for enabling or disabling an index globally. This could look somet= hing like:

ALTER INDEX index_name ENABLE;
ALTER INDEX index_name = DISABLE;

A disabled index would still receive updates and enforce co= nstraints as usual but would not be used for queries. This allows users to = assess whether an index impacts query performance before deciding to drop i= t entirely.

Implementation:
To keep this simple, I suggest= toggling the indisvalid flag in pg_index during the enable/disable operati= on.

Additional Considerations:
- Keeping the index up-to-d= ate while it=E2=80=99s disabled seems preferable, as it avoids the need to = rebuild the index if it=E2=80=99s re-enabled later. The alternative would b= e dropping and rebuilding the index upon re-enabling, which I believe would= introduce additional overhead in terms of application logic & complexi= ty.
- I am also proposing to reuse the existing indisvalid flag to avoid= adding new state and the maintenance that comes with it, but I=E2=80=99m o= pen to feedback if this approach has potential downsides.
- To keep the = scope minimal for now, I propose that we only allow enabling and disabling = indexes globally, and not locally, by supporting it exclusively in ALTER IN= DEX. I would love to know if this would break any SQL grammar promises that= I might be unaware of.

I would love to learn if this sounds like a = good=C2=A0idea and how it can be improved further. Accordingly, as a next s= tep I would be very happy to propose a patch as well.

Best regards,= =C2=A0
Shayon Mukherjee
--000000000000f1375e0621b694f4--