Re: Removing useless DISTINCT clauses - Mailing list pgsql-hackers

From Laurenz Albe
Subject Re: Removing useless DISTINCT clauses
Date
Msg-id 1521788439.2430.1.camel@cybertec.at
Whole thread Raw
In response to Re: Removing useless DISTINCT clauses  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
David Rowley wrote:
> > Would it be very difficult to extend that to "if any unique constraints are
> > contained in the DISTINCT clause"?
> 
> Unfortunately, it's quite a bit more work to make that happen. It's
> not just unique constraints that are required to make this work. We
> also need to pay attention to NOT NULL constraints too, as we're
> unable to prove function dependency when the keys have NULLs, as there
> may be any number of rows containing NULL values.
> 
> The problem is that in order to properly invalidate cached plans we
> must record the constraint OIDs which the plan depends on.  We can do
> that for PK and UNIQUE constraints, unfortunately, we can't do it for
> NOT NULL constraints as, at the moment, these are just properties of
> pg_attribute.  For this to be made to work we'd need to store those in
> pg_constraint too, which is more work that I'm going to do for this
> patch.

That makes sense; thanks for explaining.

Yours,
Laurenz Albe


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [HACKERS] proposal: schema variables
Next
From: Amit Langote
Date:
Subject: Re: [HACKERS] MERGE SQL Statement for PG11