Re: Improving a simple query?

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: swampler(at)noao(dot)edu
Cc: "Postgres-performance" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Improving a simple query?
Date: 2003-07-13 19:09:17
Message-ID: 49293.192.168.1.32.1058123357.squirrel@mainbox.archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Balazs Wellisch 2003-07-13 19:30:44 Re: Pgsql - Red Hat Linux - VS MySQL VS MSSQL
Previous Message Steve Wampler 2003-07-13 18:05:15 Improving a simple query?