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

Mihail Nikalayeu <michail.nikolaev@gmail.com>

From: Michail Nikolaev <michail.nikolaev@gmail.com>
To: Shayon Mukherjee <shayonj@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-30T16:08:18Z
Lists: pgsql-hackers
Hello.

A few comments on patch:

> + temporarily reducing the overhead of index maintenance
> +      during bulk data loading operations

>
But tuples are still inserted, where the difference come from?

> or verifying an index is not being used
> +      before dropping it

Hm, it does not provide the guarantee - index may also be used as an
arbiter for INSERT ON CONFLICT, for example. For that case, "update
pg_index set indisvalid = false" should be used before the DROP, probably.
Also index may also be used for constraint, part of partitioned table, etc.

Also, I think it is better to move check to indisvalid as if
(!index->indisvalid || !index->indisenabled).

Best regards,
Mikhail.