Re: Canonicalization of WHERE clauses considered harmful - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Canonicalization of WHERE clauses considered harmful
Date
Msg-id 8814.1071094462@sss.pgh.pa.us
Whole thread Raw
In response to Re: Canonicalization of WHERE clauses considered harmful  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-hackers
Bruno Wolff III <bruno@wolff.to> writes:
> Shouldn't it be possible to simplify
> a AND (a OR c) AND (b OR a) AND (b OR c)
> to
> a AND (b or c)
> using
> a AND (a OR x) == a

That would be one possible response, but it strikes me as a band-aid fix.
It would add quite a bit of overhead (looking to see if any OR
subclauses match any top-level clauses) on top of the rather expensive
equality checks qual_cleanup() is already making.  Another problem is
that sometimes prepqual decides not to attempt CNF-ification at all,
which means that the ability to pull out duplicate subclauses is lost
altogether.

I think it'd be cleaner to expend the cycles on a direct check for
duplicate subclauses, which we could apply independently of any decision
to convert what remains to CNF form.

We've had lots of problems with prepqual before, which is why those
heuristics about whether to try for CNF or DNF are in there; but I've
never been very happy about them.  What I'm on about now is the idea
that maybe the whole problem should be thrown overboard ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Canonicalization of WHERE clauses considered harmful
Next
From: Kurt Roeckx
Date:
Subject: Re: Canonicalization of WHERE clauses considered harmful