Re: Which query is good - IN or OR

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Which query is good - IN or OR
Date: 2010-12-09 09:51:46
Message-ID: AANLkTimJf8820LBY07+zX84rWOjHi5CJrJ_ihDqhB_S4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2010/12/9 AI Rumman <rummandba(at)gmail(dot)com>:
> A simple query I can write in any of the following two ways:
> 1.
> Select col1
> from table
> where col2 in ('A','B');
> 2.
> Select col1
> from table
> where
>  col2 = 'A'
> or  col2 = 'B'
> Here IN condition may be more than two.
> I need to know which one is good for good performance.
> Any idea please.

It depends on real use case. In almost all cases these queries are almost same.

Regards

Pavel Stehule

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Taylor 2010-12-09 11:13:58 Tuning Postgres for single user manipulating large amounts of data
Previous Message AI Rumman 2010-12-09 09:25:43 Which query is good - IN or OR