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