RpgSQL-为什么这么慢? [英] RpgSQL - Why is it so slow?
问题描述
我尝试使用 RpgSQL从R访问我的PostgreSQL数据库。
我的数据库很大,查询也很复杂。因此,我知道我必须稍等。
My database is very big and the queries are quite sophisticated. Therefore I understand that I have to wait a bit.
但是,如果我使用 pgAdmin III 作为客户端,查询可能需要5秒钟。当我使用RpgSQL时,相同的查询实际上要花很多时间。
However, if I use pgAdmin III as a client, a query takes maybe 5 seconds. When I use RpgSQL the same query literally takes ages.
我看不到原因,因为服务器而不是客户端没有做这项工作,对吧?
I can't see the reason for that, as the server and not the client hast to do the work, right?
您能给我一个原因和可能的解决方法吗?
Can you give me a reason and possibly a solution?
谢谢!
推荐答案
还有 RPostgreSQL 软件包
,该软件包正在积极维护。由于它直接位于PostgreSQL API的顶部,因此它的
应该比通过 RODBC 。
这是我在家中保存的数据库中的一个简单示例-在十分之一的时间里,它会得到一千个简单的行
一秒钟:
Here is a quick example from a database I keep at home---it gets a thousand simple rows in a tenth of a second:
R> library(RPostgreSQL)
Loading required package: DBI
R> drv <- dbDriver("PostgreSQL")
R> con <- dbConnect(drv, password="....", dbname="beancounter")
R> system.time(res <- dbGetQuery(con,
+> "select * from fxprices where date >= '2005-01-01' limit 1000"))
user system elapsed
0.030 0.000 0.113
R> dim(res)
[1] 1000 8
R>
这篇关于RpgSQL-为什么这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!