pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Expression transformation curiosity
Date: Sun, 17 Aug 2003 11:23:01 -0400
Message-ID: <11422.1061133781@sss.pgh.pa.us> (raw)
In-Reply-To: <200308171132.58073.dev@archonet.com>
References: <200308171132.58073.dev@archonet.com>

Richard Huxton <dev@archonet.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



view thread (4+ messages)  latest in thread

Message-ID: <11422.1061133781@sss.pgh.pa.us>
Permalink:  ../11422.1061133781@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11422.1061133781@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dev@archonet.com
  Subject: Re: Expression transformation curiosity
  In-Reply-To: <11422.1061133781@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox