pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: twanger@smartvia.de
To: pgsql-admin@postgresql.org
Subject: simpler query still significantly slower
Date: Wed, 23 May 2001 10:15:59 +0200 (MET DST)
Message-ID: <2144293809.990605915265.JavaMail.root@mouse.unimessage.net> (raw)

Heyho,
we tried several versions of a query which give the same results,
but the one takes 5 secs for the first time and 0.9 secs when i 
execute the query few moments later, while the other takes ~3 secs 
always. How can this be? And how can it be that the second query 
which is in fact simpler than the first takes longer?

Query 1: (5 secs vs 0.9 secs)

select 
	distinct 
	personen_id 
from 
	produktgruppen 
where 
	produktgruppen.produktgruppen_id in (
	select 
		distinct
		r_gruppen_produkte.produktgruppen_id 
	from 
		r_gruppen_produkte 
	where 
         // this and the next cond are removed in 2nd query
		r_gruppen_produkte.gruppen_id = gruppen.gruppen_id
	and 
		gruppen.parent_id=1 
	and 
		r_gruppen_produkte.gruppen_id = r_personen_bereiche.g_id 
	and 
		r_personen_bereiche.p_id = 1234
	)

Query 2: (3 secs)

select 
	distinct 
	personen_id 
from 
	produktgruppen 
where 
	produktgruppen.produktgruppen_id in (
	select 
		distinct
		r_gruppen_produkte.produktgruppen_id 
	from 
		r_gruppen_produkte 
	where 
		r_gruppen_produkte.gruppen_id = r_personen_bereiche.g_id 
	and 
		r_personen_bereiche.p_id = 1234
	)

Our system is Linux 2.2.16, gcc 2.95.2, Postgres 7.0.3 on a Pentium II 450, 128 megs

Thanks in advance

Markus Bertheau
Cenes Data GmbH




view thread (3+ messages)  latest in thread

Message-ID: <2144293809.990605915265.JavaMail.root@mouse.unimessage.net>
Permalink:  ../2144293809.990605915265.JavaMail.root@mouse.unimessage.net/
Also on:    postgresql.org/message-id/2144293809.990605915265.JavaMail.root@mouse.unimessage.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: twanger@smartvia.de
  Subject: Re: simpler query still significantly slower
  In-Reply-To: <2144293809.990605915265.JavaMail.root@mouse.unimessage.net>
  References: <2144293809.990605915265.JavaMail.root@mouse.unimessage.net>

* 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