Large OR query

From: Zak McGregor <zak(at)mighty(dot)co(dot)za>
To: pgsql-general(at)postgresql(dot)org
Subject: Large OR query
Date: 2001-06-12 12:42:14
Message-ID: 20010612144214.1ecde1d3.zak@mighty.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

If I have say 1000 values for an ID field, what is the best way to
select from a table all the corresponding records?
I have tried
select * from blah where id in (id1,id2,id3...id1000)
and
select * from blah where id=id1 or id=id2 ... or id=id1000

and both are pretty slow.
Is there a better way to do this please?

Thanks

Ciao
--
Zak McGregor http://www.carfolio.com - Over 7000 car specs online
Web mercenary - currently for hire. Perl/html/.js/sql/cgi/GNUlinux/php +
---------------------------------------------------------------------
"Trying to make bits uncopyable is like trying to make water not wet.
The sooner people accept this, and build business models that take
this into account, the sooner people will start making money again."
-- Bruce Schneier

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martín Marqués 2001-06-12 12:53:22 Re: [SQL] ORDER BY what?
Previous Message Paul Tomblin 2001-06-12 11:30:19 Re: What the heck is happening here?