>
> > 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.

Reply via email to