Re: Disallow redundant indexes - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Disallow redundant indexes
Date
Msg-id CADkLM=edW3k4nK9f-mvtYbrh_q=5xQYtGvRjL3Ja5uYDK+SK4Q@mail.gmail.com
Whole thread Raw
In response to Re: Disallow redundant indexes  (Japin Li <japinli@hotmail.com>)
Responses Re: Disallow redundant indexes
List 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.


 

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Parallel heap vacuum
Next
From: Alexander Lakhin
Date:
Subject: Re: optimize file transfer in pg_upgrade