[R] RMySQL question, sql with R vector or list
Chris Stubben
stubben at lanl.gov
Tue Jun 5 20:53:40 CEST 2007
> dynamically, rather than statically like using paste. One concern using
> paste to construct the SQL command is this: what about if the ID list in
> your sample becomes very large, is this a problem to construct this way?
>
I have not messed with procedures in mysql 5, so I have no idea about the first
question. However, the IN operator should be fast, even for large vectors.
It takes me a second to retrieve 10,000 random records from a table with
100,000+ rows.
system.time(id.in( sample(1:100000, 10000) ))[3]
[1] 1.07
Also, I forgot to mention this before - if your ID is a character field, you
can quote strings in the IN clause using the shell quote function.
paste(shQuote(ids),collapse=",")
Chris
More information about the R-help
mailing list