Re: Disallow redundant indexes

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Japin Li <japinli(at)hotmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Disallow redundant indexes
Date: 2025-04-24 12:26:14
Message-ID: CAKAnmmLvud8U0pD0Lryq=U_2Hv++OSUtsCpxTEM+58OB9mHC5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 24, 2025 at 7:31 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:

> On Thu, 24 Apr 2025 at 21:27, Japin Li <japinli(at)hotmail(dot)com> wrote:
> > I propose that PostgreSQL prevent redundant index creation by:

> In any case, who are we to define what a duplicate index is?

I think this part is easier than you make it sound: everything (except the
name) is exactly the same as an existing index. That's the 99% case we are
trying to catch here.

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.

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-04-24 12:30:07 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Bruce Momjian 2025-04-24 12:11:52 pg_upgrade-breaking release