Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-admin by date

Next:From: Tom LaneDate: 2007-12-13 01:03:15
Subject: Re: WHERE clause OR vs IN
Previous:From: Medi MontaseriDate: 2007-12-12 23:30:31
Subject: Re: WHERE clause OR vs IN

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group