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 8947.1071095711@sss.pgh.pa.us
Whole thread Raw
In response to Re: Canonicalization of WHERE clauses considered harmful  (Kurt Roeckx <Q@ping.be>)
Responses Re: Canonicalization of WHERE clauses considered harmful  (Kurt Roeckx <Q@ping.be>)
List pgsql-hackers
Kurt Roeckx <Q@ping.be> writes:
> On Wed, Dec 10, 2003 at 04:54:54PM -0500, Tom Lane wrote:
>> (a AND b) OR (a AND c)
>> expands by repeated application of the distributive law to
>> (a OR a) AND (a OR c) AND (b OR a) AND (b OR c)

> This is wrong.

I don't think so.  The distributive law is
a OR (b AND c) == (a OR b) AND (a OR c)

Starting from
(a AND b) OR (x AND y)

prepqual.c applies the law once to produce
((a AND b) OR x) AND ((a AND b) OR y)

and then twice more to obtain
(a OR x) AND (b OR x) AND (a OR y) AND (b OR y)

Taking a equal to x gives the case I quoted.

The real problem is that we want to run the distributive law backwards,
not forwards ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Kurt Roeckx
Date:
Subject: Re: Canonicalization of WHERE clauses considered harmful
Next
From: Jason Tishler
Date:
Subject: Re: postgres panic error