pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Wampler <swampler@noao.edu>
To: pgsql-sql@postgresql.org
Subject: Replacing a simple nested query?
Date: Sun, 13 Jul 2003 14:50:42 -0700
Message-ID: <20030713215042.GA18643@weaver.tuc.noao.edu> (raw)


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@noao.edu
Quantum materiae materietur marmota monax si marmota
                    monax materiam possit materiari?



view thread (3+ messages)  latest in thread

Message-ID: <20030713215042.GA18643@weaver.tuc.noao.edu>
Permalink:  ../20030713215042.GA18643@weaver.tuc.noao.edu/
Also on:    postgresql.org/message-id/20030713215042.GA18643@weaver.tuc.noao.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: swampler@noao.edu
  Subject: Re: Replacing a simple nested query?
  In-Reply-To: <20030713215042.GA18643@weaver.tuc.noao.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox