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

From Tom Lane
Subject Re: [SQL] query with subquery abnormally slow?
Date
Msg-id 2748.941494228@sss.pgh.pa.us
Whole thread Raw
In response to query with subquery abnormally slow?  (Oskar Liljeblad <osk@hem.passagen.se>)
List pgsql-sql
Oskar Liljeblad <osk@hem.passagen.se> writes:
> 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)

Have you considered something like

select i1.* from items i1, items i2 where
i1.package = i2.package and i2.performer ~ '...';

This would only be fast given an index on package, I think,
but you said you had one...
        regards, tom lane


pgsql-sql by date:

Previous
From: Oskar Liljeblad
Date:
Subject: Re: [SQL] query with subquery abnormally slow?
Next
From: Chris Griffin
Date:
Subject: SQL Info