Re: Large OR query

From: "Mitch Vincent" <mvincent(at)cablespeed(dot)com>
To: "Zak McGregor" <zak(at)mighty(dot)co(dot)za>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Large OR query
Date: 2001-06-12 14:25:25
Message-ID: 00a301c0f34e$cc123d80$1251000a@Mitch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is populating another table with the 1000 values and doing a
SELECT * FROM <whatever> WHERE <something> IN (SELECT <something> FROM
<whatever>) ?

I'm not entirely sure that it will yield a better result but it's worth a
try.

-Mitch

----- Original Message -----
From: "Zak McGregor" <zak(at)mighty(dot)co(dot)za>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Tuesday, June 12, 2001 8:42 AM
Subject: [GENERAL] Large OR query

> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alla 2001-06-12 14:32:37 Please help! Functions passing records between them
Previous Message Mitch Vincent 2001-06-12 14:22:12 Re: How many no. of clients can access database simultaneously?