Subject | Re: [firebird-support] "IN" and several "=" and "and" |
---|---|
Author | Ivan Prenosil |
Post date | 2005-05-25T06:20:10Z |
> which performs much fasterThe first one will be faster because it will return nothing :-)
>
> select *
> from table
> where id = 1 and id = 2 and id = 4 and id = 6 and id = 8 and id = 10
>
> or
>
> select *
> from table
> where id in (1, 2, 4, 6, 8, 10)
>
> The ID field is a primary key. And what if the field is not an index
> key is there a need to be indexed for better performance.
But if you want to compare these two
where id = 1 or id = 2 or id = 4 or id = 6 or id = 8 or id = 10
where id in (1, 2, 4, 6, 8, 10)
that they are internally processed identically.
Ivan
http://www.volny.cz/iprenosil/interbase/