Re: Improving a simple query? - Mailing list pgsql-performance

From Richard Huxton
Subject Re: Improving a simple query?
Date
Msg-id 49293.192.168.1.32.1058123357.squirrel@mainbox.archonet.com
Whole thread Raw
In response to Improving a simple query?  (Steve Wampler <swampler@noao.edu>)
Responses Re: Improving a simple query?
List pgsql-performance
> I'm not an SQL or PostgreSQL expert.
>
> I'm getting abysmal performance on a nested query and
> need some help on finding ways to improve the performance:
[snip]
>  select * from attributes_table where id in (select id from
>       attributes where (name='obsid') and (value='oid00066'));

This is the classic IN problem (much improved in 7.4 dev I believe). The
recommended approach is to rewrite the query as an EXISTS form if
possible. See the mailing list archives for plenty of examples.

Could you not rewrite this as a simple join though?

- Richard

pgsql-performance by date:

Previous
From: Steve Wampler
Date:
Subject: Improving a simple query?
Next
From: "Balazs Wellisch"
Date:
Subject: Re: Pgsql - Red Hat Linux - VS MySQL VS MSSQL