Re: [SQL] query with subquery abnormally slow? - Mailing list pgsql-sql

From Oskar Liljeblad
Subject Re: [SQL] query with subquery abnormally slow?
Date
Msg-id 19991101211030.A8132@oskar
Whole thread Raw
In response to query with subquery abnormally slow?  (Oskar Liljeblad <osk@hem.passagen.se>)
Responses Re: [SQL] query with subquery abnormally slow?
List pgsql-sql
On Mon, Nov 01, 1999 at 07:47:07PM +0100, Oskar Liljeblad wrote:
> I'm doing a SELECT query with a subquery on a table with 12K rows
> but it is very slow (10 seconds+). The query looks like this:
> 
>   select *
>     from items
>     where package in
>       (select package
>          from items
>          where ...blah...
>          group by package)

I could do it much faster with this query:
 select distinct i2.package, i1.* from items i1, items i2 where i1.package = i2.package and ...blah...

but it is still at least three times slower than
doing the subquery first, and for each row in the
result another query. Any ideas?

Oskar Liljeblad (osk@hem.passagen.se)


pgsql-sql by date:

Previous
From: "Moray McConnachie"
Date:
Subject: Re: [SQL] query with subquery abnormally slow?
Next
From: Bill Brandt
Date:
Subject: Re: [SQL] query with subquery abnormally slow?