Sander Jansen <[email protected]> wrote: > Suppose I have query that does: > > SELECT .... FROM table WHERE someinteger IN ( 2,18,19,340,1,72, 15 > .... ); > > The list of numbers comes from a user selection, so it doesn't come > from some other table. Would it make a big difference in performance > if I pre-sort this list of numbers or does SQLITE automatically sort > this (and perhaps maintains an index as well)?
Looking at EXPLAIN output for such a query, SQLite creates ephemeral (in-memory) B-tree for the list of integers (essentially, just the index without the underlying table). So, the numbers will be automatically arranged into B-tree for fast lookup: their order in the query is irrelevant (except perhaps for the marginal speed-up in adding them to the B-tree in the first place, which is probably slightly faster if the numbers are pre-sorted - but if you don't happen to have them sorted already, you'll probably spend as much time doing so as SQLite would). Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

