SQLilte query much slower through RSqlite than sqlite3 command-line interface

只愿长相守 提交于 2021-02-07 05:21:30

问题


I'm using the RSQLite package to make queries to a local SQLite database, and for some queries the RSQLite interface is quite slow.

As a specific example, the following query takes under one second to run using the sqlite3 command-line utility:

$ sqlite3 data/svn.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select count(distinct svn_path.revision)  FROM src INNER JOIN svn_path ON src.filename=svn_path.path;
5039

But the equivalent query in R takes a little over two minutes and uses 100% of one of my CPUs:

> library(RSQLite)
Loading required package: DBI
> con <- dbConnect(SQLite(), dbname="data/svn.db")
> dbGetQuery(con, "select count(distinct svn_path.revision)  FROM src INNER JOIN svn_path ON src.filename=svn_path.path")
  count(distinct svn_path.revision)
1                              5039

Why is the performance so much slower through the R interface?

Note that I'm using R64 2.10.1 on Mac OS X 10.6.6.


回答1:


What matters is the version of RSQLite you have. Your version of R seems to be over a year old so if your RSQLite is just as old it could be a much older engine (eg, 3.6.4) as suggested by Benoit.



来源:https://stackoverflow.com/questions/5145054/sqlilte-query-much-slower-through-rsqlite-than-sqlite3-command-line-interface

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!