Skip site navigation (1) Skip section navigation (2)

Re: mysterious difference in speed when combining two queries with OR

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: mysterious difference in speed when combining two queries with OR
Date: 2008-04-23 08:57:04
Message-ID: 20080423085704.GG8401@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-performance
am  Wed, dem 23.04.2008, um  9:58:10 +0200 mailte A. Kretschmer folgendes:
> > Query A (two queries)
> > 
> > select distinct moment.mid from moment,timecard where parent = 45 and (pid=17 and timecard.mid = moment.mid) order by moment.mid;
> > select distinct moment.mid from moment,timecard where parent = 45 and (pbar = 0) order by moment.mid;
> > 
> > Query B (combining the two with OR)
> > 
> > select distinct moment.mid from moment,timecard where parent = 45 and ((pid=17 and timecard.mid = moment.mid) or (pbar = 0)) order by moment.mid;

Thanks to depesz on #postgresql (irc-channel):

Query A, the second query: there are no join between the 2 tables.
Mistake?


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

In response to

Responses

pgsql-performance by date

Next:From: hansDate: 2008-04-23 09:06:08
Subject: Re: mysterious difference in speed when combining twoqueries with OR
Previous:From: Craig RingerDate: 2008-04-23 08:28:05
Subject: Re: SELECT 'DBD::Pg ping test'

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group