Re: Canonicalization of WHERE clauses considered harmful

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Canonicalization of WHERE clauses considered harmful
Date: 2003-12-10 22:14:22
Message-ID: 8814.1071094462@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruno Wolff III <bruno(at)wolff(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kurt Roeckx 2003-12-10 22:19:56 Re: Canonicalization of WHERE clauses considered harmful
Previous Message Bruno Wolff III 2003-12-10 22:04:39 Re: Canonicalization of WHERE clauses considered harmful