On 25 Jan 2010, at 1:40pm, Tim Romano wrote:

> What is the maximum number of literal values that can be put inside the IN ( 
> ) list ?
> 
>     select * from T  where aColumn in (1,2,3,4,...)

If you are using any more than a few values for IN, then using IN is probably 
not the way to go.  Make another table with all your valid values, and use a 
JOIN to get the results you want.

> I didn't see the answer here:   http://www.sqlite.org/limits.html
> 
> My queries could have more than 255 values from time to time

How many more ?  1000 ?

That limit is higher than you're worried about.  However, there are other 
limits which are inherent in processing a SELECT command.  For instance there's 
a limit on the total length of the SELECT command expressed as a string.  And a 
limit on the total number of tokens the command is turned into.   And, of 
course, the longer the command, the slower it will be processed.

> BTW, the remote client is passing these explilcit values over the internet to 
> the server --i.e.  the query cannot be rewritten as follows:
> 
>    select * from T where aColumn in ( select values from T2 where...)
> 
> at least not without creating temporary tables to hold the value-list sent by 
> the client.

Ah, you agree with my suggestion (the sub-select is more usually represented as 
a JOIN, sometimes with T2 as the primary rather than the joined table).  Is 
there a problem creating the temporary table ?

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to