IN vs individual queries, performance comparison
am 20.07.2006 00:48:50 von bennett.matthew
Hello,
If I needed to fetch 3 entries from a database, is there a significant
performance difference between the following?
SELECT * FROM JOBS WHERE myCol IN ('val1','val2',val3');
Versus
SELECT * FROM JOBS WHERE myCol ='val1';
SELECT * FROM JOBS WHERE myCol ='val2';
SELECT * FROM JOBS WHERE myCol ='val3';
Many thanks,
Matt.
Re: IN vs individual queries, performance comparison
am 23.07.2006 20:51:07 von Michael Austin
bennett.matthew@gmail.com wrote:
> Hello,
>
> If I needed to fetch 3 entries from a database, is there a significant
> performance difference between the following?
>
> SELECT * FROM JOBS WHERE myCol IN ('val1','val2',val3');
>
> Versus
>
> SELECT * FROM JOBS WHERE myCol ='val1';
> SELECT * FROM JOBS WHERE myCol ='val2';
> SELECT * FROM JOBS WHERE myCol ='val3';
>
> Many thanks,
> Matt.
>
you are kidding, right? think about what happens during each "individual" query
- what if that table has 500,000 records - which is faster.
Just in case you were also wondering, the "IN" clause is an implicit "OR".
(where a=1 or a=2 or a=3...)
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)