Re: Replacing a simple nested query?

From: Joe Conway <mail(at)joeconway(dot)com>
To: Steve Wampler <swampler(at)noao(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Replacing a simple nested query?
Date: 2003-07-13 22:01:13
Message-ID: 3F11D6A9.4040905@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-sql

Steve Wampler wrote:
> I've got a simple nested query:
>
> select * from attributes where id in (select id from
> attributes where (name='obsid') and (value='oid00066'));
>
> that performs abysmally. I've heard this described as the
> 'classic WHERE IN' problem.

I may be missing something, but why can't you just do:
select * from attributes where name='obsid' and value='oid00066';
?

Joe

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jim C. Nasby 2003-07-13 22:32:14 Re: Pgsql - Red Hat Linux - VS MySQL VS MSSQL
Previous Message Steve Wampler 2003-07-13 21:50:42 Replacing a simple nested query?

Browse pgsql-sql by date

  From Date Subject
Next Message markus brosch 2003-07-14 12:57:19 Re: max length of sql select statement (long!)
Previous Message Steve Wampler 2003-07-13 21:50:42 Replacing a simple nested query?