Re: [R] RMySQL question, sql with R vector or list

From: Chris Stubben <stubben_at_lanl.gov>
Date: Tue, 05 Jun 2007 18:53:40 +0000 (UTC)

> 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



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Jun 2007 - 19:34:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Jun 2007 - 20:33:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.