Re: [PATCH] Deferrable unique constraints vs join removal -- bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Marti Raudsepp <marti(at)juffo(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Deferrable unique constraints vs join removal -- bug?
Date: 2011-10-23 03:44:59
Message-ID: 21200.1319341499@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> Yuck. Well, that's certainly a bug. What's weird is that I thought
> we had put logic into the join removal code to ignore deferrable
> constraints. Apparently not.

I poked around a bit more and could not find any evidence that we'd
ever done that. Ah well.

> I think maybe what we should do is add
> an "immediate" field to IndexOptInfo, mirroring the existing unique
> flag, and have get_relation_info() populate it from indimmediate, and
> then make relation_has_unique_index() disqualify any non-immediate
> index.

Yeah, this seems like the right fix. I considered redefining the unique
flag to mean indisunique && indimmediate, but that's wrong because of:

> has_unique_index() arguably needs a similar fix, although at present
> that appears to be used for only statistic purposes, so maybe it's OK.

Yes, since this is meant for statistical purposes, I think it's
appropriate for it to disregard indimmediate.

> A comment update might be a good idea, though.

Or we could add a parameter to have the caller indicate which behavior
is wanted. But for now I think a comment is enough.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2011-10-23 09:00:30 Re: synchronized snapshots
Previous Message Tom Lane 2011-10-23 03:14:48 Re: So, is COUNT(*) fast now?