Subject Re: [firebird-support] "IN" and several "=" and "and"
Author Ivan Prenosil
> which performs much faster
>
> 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.

The first one will be faster because it will return nothing :-)

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/