有没有办法使用MonetDB.R进行批量插入(而不是通过for循环和dbSendUpdate)?
dbWriteTable允许更新(append=TRUE)吗?
关于“插入到”MonetDB文档中写道:“好处很明显:这非常简单。然而,在MonetDB中这是一种非常低效的处理方式。”
谢谢。
发布于 2014-07-11 22:16:09
Hannes可能有一个更聪明的解决方案,但就目前而言,这可能会有所帮助:)
# start with an example data set
nrow( mtcars )
# and a MonetDB.R connection
db
# here's how many records you'd have if you stack your example data three times
nrow( mtcars ) * 3
# write to three separate tables
dbWriteTable( db , 'mtcars1' , mtcars )
dbWriteTable( db , 'mtcars2' , mtcars )
dbWriteTable( db , 'mtcars3' , mtcars )
# stack them all
dbSendUpdate( db , "CREATE TABLE mtcars AS SELECT * FROM mtcars1 UNION ALL SELECT * FROM mtcars2 UNION ALL SELECT * FROM mtcars3 WITH DATA" )
# correct number of records
nrow( dbReadTable( db , 'mtcars' ) )发布于 2014-07-14 16:24:12
我会考虑的。monetdb.read.csv确实使用了复制到,因此您可以轻松地创建临时文件。CSV文件。
发布于 2014-07-12 18:14:25
我明白你的意思,尽管这并没有改变dbWriteTable使用for循环和"INSERT INTO“的事实,这可能会相当慢。我可能在最初的帖子中说得不是很清楚。
作为一种变通方法,我猜dbSendUpdate的“启动事务”和“提交”可能会起作用。
理想情况下,像这样的东西会很棒:
“从data.frame复制到表中”
https://stackoverflow.com/questions/24694751
复制相似问题