Replacing a simple nested query?

From: Steve Wampler <swampler(at)noao(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Replacing a simple nested query?
Date: 2003-07-13 21:50:42
Message-ID: 20030713215042.GA18643@weaver.tuc.noao.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-sql


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.

Is there a better way to obtain the same results? The inner
select identifies a set of ids (2049 of them, to be exact)
that are then used to locate records that have the same id
(about 30-40K of those, including the aforementioned 2049).

Thanks!
-Steve

--
Steve Wampler -- swampler(at)noao(dot)edu
Quantum materiae materietur marmota monax si marmota
monax materiam possit materiari?

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Joe Conway 2003-07-13 22:01:13 Re: Replacing a simple nested query?
Previous Message Steve Wampler 2003-07-13 20:46:10 Re: Improving a simple query?

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2003-07-13 22:01:13 Re: Replacing a simple nested query?
Previous Message Jo 2003-07-13 16:32:22 How to write this query!