Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4SCUtA93570 for ; Mon, 28 May 2001 08:30:55 -0400 (EDT) (envelope-from pgsql-admin-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4NBvoA28191 for ; Wed, 23 May 2001 07:57:50 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f4NBS3c09583 for pgsql-admin@postgresql.org; Wed, 23 May 2001 07:28:03 -0400 (EDT) (envelope-from news) From: "Murat YILDIZ" X-Newsgroups: comp.databases.postgresql.admin Subject: Re: simpler query still significantly slower Date: Wed, 23 May 2001 14:26:23 +0300 Organization: Boytas Mobilya A.S. Lines: 72 Message-ID: <9eg6s1$9bc$1@news.tht.net> References: <2144293809.990605915265.JavaMail.root@mouse.unimessage.net> Reply-To: "Murat YILDIZ" X-Complaints-To: scrappy@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 To: pgsql-admin@postgresql.org X-Archive-Number: 200105/152 X-Sequence-Number: 1512 use the "explain select ....."option and paste the outputs for both queries... wrote in message news:2144293809.990605915265.JavaMail.root@mouse.unimessage.net... > 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 > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://www.postgresql.org/search.mpl