Re: Canonicalization of WHERE clauses considered harmful

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kurt Roeckx <Q(at)ping(dot)be>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Canonicalization of WHERE clauses considered harmful
Date: 2003-12-10 22:35:11
Message-ID: 8947.1071095711@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kurt Roeckx <Q(at)ping(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jason Tishler 2003-12-10 22:55:50 Re: postgres panic error
Previous Message Kurt Roeckx 2003-12-10 22:19:56 Re: Canonicalization of WHERE clauses considered harmful