pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gregory Stark <stark@enterprisedb.com>
To: Hans Ekbrand <hans.ekbrand@sociology.gu.se>
Cc: pgsql-performance@postgresql.org
Subject: Re: mysterious difference in speed when combining two queries with OR
Date: Wed, 23 Apr 2008 09:31:39 -0400
Message-ID: <873apcu284.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <20080423092205.GI11886@amin>
References: <20080423072303.GF11886@amin>
	<20080423075810.GB8401@a-kretschmer.de>
	<20080423085704.GG8401@a-kretschmer.de>
	<20080423092205.GI11886@amin>

"Hans Ekbrand" <hans.ekbrand@sociology.gu.se> writes:

> No, I just wanted to show the time differences, I haven't used join
> before. Now that you have adviced me to, I have tried your suggestion
> to rewrite B as a union and it works good! Just as fast as the A Query!

You can even do better. If you know the two sets of mid are disjoint you can
use UNION ALL. If not you could remove the two DISTINCTs as the UNION will
take care of removing duplicates.

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's On-Demand Production Tuning



view thread (8+ messages)

Message-ID: <873apcu284.fsf@oxford.xeocode.com>
Permalink:  ../873apcu284.fsf@oxford.xeocode.com/
Also on:    postgresql.org/message-id/873apcu284.fsf@oxford.xeocode.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-performance@postgresql.org
  Cc: stark@enterprisedb.com, hans.ekbrand@sociology.gu.se
  Subject: Re: mysterious difference in speed when combining two queries with OR
  In-Reply-To: <873apcu284.fsf@oxford.xeocode.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