[R] RMySQL question

Aaron J. Mackey amackey at pcbi.upenn.edu
Thu Jun 3 16:50:55 CEST 2004

Yes, of course paste() works; the question is about getting more 
efficient query execution by preparing statements with placeholders in 
advance (as opposed to paste()-ing together a new SQL statement for 
every single statement execution, and requiring the database to 
reinterpret/recompile it every time).

The response about prepared statements only available in 4.1 was a bit 
odd to me at first, since in the Perl DBI world we've been preparing 
and binding for along time now with DBD::mysql; in that case though, 
the optimization is really one of DBI's, not MySQL's.  4.1 will bring 
that level of optimization to the database.

So to truly answer the OP's question, there is no prepare/bind facility 
in RMySQL, nor does there need to be one to get the same level of 
performance as seen in DBD::mysql (but in the future, both DBD::mysql 
and RMySQL may get even faster if they start using the MySQL API for 
prepared statements).  The additional affect of proper quoting provided 
by the DBI's binding facility is available to you via RMySQL's quote() 
function (if memory serves me right ... it's been awhile).


On Jun 3, 2004, at 9:46 AM, Wolski wrote:

> ?paste
> works fine for me.
> On 6/3/2004 at 9:32 AM Sean Davis wrote:
>>>> In perl DBI, there is a method for preparing sql commands with
>>>> wildcards and
>>>> then executing them with parameter bindings.  Is there a way to do 
>>>> this
>>>> within RMySQL?  I would like to be able to look up values in a table
>>>> based
>>>> on a key supplied from R.

More information about the R-help mailing list