Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

From: Benoit Lobréau <benoit(dot)lobreau(at)gmail(dot)com>
To: Shayon Mukherjee <shayonj(at)gmail(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)
Date: 2025-01-24 10:32:52
Message-ID: CAPE8EZ6tdCRzz1PuYgFPnRe5chtTpHCfWfWzU7sJKfuMQHMeZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Thank you for the patch! I've had a need for this feature several times,
so I appreciate the work you’ve put into it.

I like the new name VISIBLE/INVISIBLE and the fact that it's a separate flag in
pg_index (it's easy to monitor).

I don’t feel qualified to provide an opinion on the code itself just yet.

I did notice something in the command prototype:

+ALTER INDEX [ IF EXISTS ] <replaceable
class="parameter">name</replaceable> VISIBLE
+ALTER INDEX [ IF EXISTS ] <replaceable
class="parameter">name</replaceable> INVISIBLE

it would probably be better as:

+ALTER INDEX [ IF EXISTS ] <replaceable
class="parameter">name</replaceable> {VISIBLE|INVISIBLE}

The completion for the INVISIBLE / VISIBLE keyword is missing in psql.

I also tested the ALTER command within a transaction, and it worked as I
expected: the changes are transactional (possibly because you didn’t use
systable_inplace_update_begin?).

Additionally, I tried using the ALTER command on an index that supports
a foreign key. As expected, delete and update operations on the referenced
table became significantly slower. I was wondering if this behavior should
be documented here.

+ Make the specified index invisible. The index will not be used
for queries.
+ This can be useful for testing query performance with and
without specific
+ indexes.

Maybe something like :

The index will not be used for user or system queries (e.g., an index
supporting foreign keys).

I noticed that you mentionned checking pg_stat_user_indexes before using
the query but it might not be enough?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-01-24 10:47:36 Re: doc: explain pgstatindex fragmentation
Previous Message Andrei Lepikhov 2025-01-24 10:17:41 Re: Showing applied extended statistics in explain Part 2