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