One more question though,

Is there a way to use a prepared statement and bind a (variable) array
of integers?

Like in:
SELECT .... FROM table WHERE someinteger IN ( 2,18,19,340,1,72, 15 ... )

Becomes:
SELECT .... FROM table WHERE someinteger IN ( ? )

Thanks,
Sander

On Mon, Dec 15, 2008 at 4:16 PM, Igor Tandetnik <[email protected]> wrote:
> 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
>



-- 
"And any fool knows a dog needs a home
A shelter from pigs on the wing"
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to