Re: Disallow redundant indexes

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Disallow redundant indexes
Date: 2025-04-28 17:51:52
Message-ID: CADkLM=edW3k4nK9f-mvtYbrh_q=5xQYtGvRjL3Ja5uYDK+SK4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > I've had this idea before, and even wrote a quick POC at one point, but
> I had it simply throw a warning rather than an
> > error. That avoids the need for any GUC, which I agree is not a good
> idea. And it still allows people to create a
> > duplicate index if they really want to.
> >
>
> I also appreciate your suggestion regarding the GUC parameter. You've
> convinced me that a warning might be a more appropriate approach. A
> warning
> would still alert users to the potential issue of creating a redundant
> index,
> while allowing them to proceed if they have a specific reason to do so.

+1 to a warning.

One reason they might want to create a duplicate index is to reduce index
bloat, especially on partial indexes. Granted, we've had REINDEX
CONCURRENTLY since v12, but some reindexing workflows are older than that,
and I've seen a few that put a "freshness date" into the index name as a
hint to future DBAs about the urgency of the next reindexing. A canceled
reindex concurrently could in the past (and maybe still can) leave an
invalid index of indeterminate name, and therefore harder to clean up, so
that's a possible reason to prefer duplicate-then-swap index creation over
reindex.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2025-04-28 18:00:01 Re: optimize file transfer in pg_upgrade
Previous Message Masahiko Sawada 2025-04-28 17:51:42 Re: Parallel heap vacuum