Re: Expression transformation curiosity

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Expression transformation curiosity
Date: 2003-08-17 15:23:01
Message-ID: 11422.1061133781@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Huxton <dev(at)archonet(dot)com> writes:
> Boiling the problem down, I've looked at a clause of the form:
> a OR (b AND c)
> which PG converts to:
> (a OR b) AND (a OR c)

> Is it an artefact of displaying the EXPLAIN, or is it actually
> processed that way? You could see how testing "a" twice could be
> expensive in some situations.

It's actually done that way --- see the comments near the head of
src/backend/optimizer/prep/prepqual.c. There are some heuristics
to not do it if the expression expands "a lot", though.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Alexander M. Pravking 2003-08-17 15:39:38 Re: Expression transformation curiosity
Previous Message Richard Huxton 2003-08-17 10:32:58 Expression transformation curiosity