Re: query slow problem - Mailing list pgsql-general

From Andrew Sullivan
Subject Re: query slow problem
Date
Msg-id 20020729114527.G13977@mail.libertyrms.com
Whole thread Raw
In response to query slow problem  ("frank_lupo" <frank_lupo@email.it>)
List pgsql-general
On Mon, Jul 29, 2002 at 05:16:40PM +0200, frank_lupo wrote:
> select id,de2 from irtab where id in (select distinct(ruolofunz) from
> irelbtes_1 where entpian=118331)\g

Don't use IN.  It's slow.  Try this:

select id,de2 from irtab where exists (select distinct(ruolofunz)
from irelbtes_1 where entpian=118331 and ruolofunz=id)

Or maybe

select distinct on (ruolofunz) id, de2 from irtab, irelbtes_1 where
id = ruolofunz and entpian=118331

A

--
----
Andrew Sullivan                               87 Mowat Avenue
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M6K 3E3
                                         +1 416 646 3304 x110


pgsql-general by date:

Previous
From: "Markus Wollny"
Date:
Subject: Re: tsearch - Regression tests fail
Next
From: Oleg Bartunov
Date:
Subject: Re: Using FTI-Search (likely a more general