I don't think so. If the field has been indexed, searching speed will be imprved very much. The query "f1 = value1 OR f1 = value2 OR f1=value3 OR ..." will be faster if the field f1 has been indexed. On the other hand, the clause "f1 in (value1, value2, value3, ...)" seems to be slower then 'OR' clause because i think it will get the all value of 'f1' and check whether the f1's value is in (value1, value2, value3, ...). If the table has 100K records, it will compare 100K times, in contrast, the OR clause only need compare few times because of the index when the number of values in (value1, value2, value3, ...) list is not too big.
2007/2/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
Ion Silvestru <[EMAIL PROTECTED]> wrote: > If we have a query where we compare a column to a set of values, then > which is faster: OR or IN? > Ex: OR: (mycol = "a") OR (mycol = "b") OR (mycol = "c") OR... > IN: (mycol IN "a", "b", "c" ...) > IN is faster. However, version 3.2.3 introduced an enhancement to the SQLite optimizer that automatically converts the OR form of the expression above into the IN form, thus taking advantage of the increased speed of IN. So for SQLite version 3.2.3, there really is no difference between the two. See http://www.sqlite.org/optoverview.html#or_opt -- D. Richard Hipp <[EMAIL PROTECTED]> ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------
-- powered by python