Re: WHERE clause OR vs IN

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Medi Montaseri <montaseri(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: WHERE clause OR vs IN
Date: 2007-12-13 00:37:45
Message-ID: 359993.87392.qm@web31808.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

--- On Wed, 12/12/07, Medi Montaseri <montaseri(at)gmail(dot)com> wrote:

> based on your report, run time of OR is 0.275 ms and IN is
> 0.314
>
> > postgres=# explain analyze select * from tellers where
> bid in ('1','2');

Two other options are:

SELECT *
FROM Tellers
WHERE bin = ANY( '1', '2' );

and

SELECT T.*
FROM Tellers AS T
INNER JOIN ( VALUES ( '1' ), ( '2' ) ) AS B( bin )
ON T.bin = B.bin;

Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2007-12-13 01:03:15 Re: WHERE clause OR vs IN
Previous Message Medi Montaseri 2007-12-12 23:30:31 Re: WHERE clause OR vs IN