pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Alexander M. Pravking <fduch@antar.bryansk.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: Expression transformation curiosity
Date: Sun, 17 Aug 2003 18:01:23 +0100
Message-ID: <200308171801.23667.dev@archonet.com> (raw)
In-Reply-To: <20030817153938.GA437@dyatel.antar.bryansk.ru>
References: <200308171132.58073.dev@archonet.com>
	<20030817153938.GA437@dyatel.antar.bryansk.ru>

On Sunday 17 August 2003 16:39, Alexander M. Pravking wrote:
> On Sun, Aug 17, 2003 at 11:32:58AM +0100, Richard Huxton wrote:
> > 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.
>
> Looks like it actually works this way.
> I had the same problem several weeks ago on 7.3.3 with 4 such OR's.
> The final filter became monsterous, and the query was very slow.
>
> I've simply rewritten the query using UNION, and it became much faster.

Doesn't seem to matter much in this case, although I tried it as a UNION just 
to check the results were the same.

Thanks Alexander
-- 
  Richard Huxton
  Archonet Ltd



view thread (4+ messages)

Message-ID: <200308171801.23667.dev@archonet.com>
Permalink:  ../200308171801.23667.dev@archonet.com/
Also on:    postgresql.org/message-id/200308171801.23667.dev@archonet.com

 · 

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: dev@archonet.com, fduch@antar.bryansk.ru
  Subject: Re: Expression transformation curiosity
  In-Reply-To: <200308171801.23667.dev@archonet.com>

* 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