Re: DROP INVALID INDEXES command

From: Roman Khapov <rkhapov(at)yandex-team(dot)ru>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Kirill Reshke <reshkekirill(at)gmail(dot)com>
Subject: Re: DROP INVALID INDEXES command
Date: 2026-07-01 12:44:17
Message-ID: 82E6F954-144A-42A5-9586-36288297F61B@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi! Thanks for review!

> I think the patch should include some tests. (Probably the behavior we want is that the
> code simply ignores any indexes it cannot obtain an AEL on.)
>

Attached V2 with simple test, that can be extended with test for parallel REINDEX CONCURRENTLY. On our tests it really creates deadlock... so the idea of

> ignoring invalid indexes looks like a reasonable workaround for me
>

and the syntax of SKIP LOCKED looks good for me too, can add it in
next version.

>
> On the other hand, I wouldn't be opposed to having the feature you want,
> using a straight function as user interface (SELECT
> pg_drop_invalid_indexes()).

Seems like current implementation can be expanded with support of
DROP INVALID INDEXES IN DATABASE/SCHEMA (ex: for table with partitions)
maybe it is an advantage over functions, in addition to <tab> completion.

Also, seems like lock behavior it can not be implemented with functions, but currently
we have no agreement with that, so maybe it is not the reason, to do it in DDL..

--
Best regards,
Roman Khapov

Attachment Content-Type Size
v2-0001-Add-DROP-INVALID-INDEXES-ON-TABLE-command.patch application/octet-stream 16.0 KB
unknown_filename text/plain 2 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2026-07-01 13:09:52 Re: RFC: Logging plan of the running query
Previous Message Ewan Young 2026-07-01 12:32:05 Re: Fix jsonpath .decimal() to honor silent mode