Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source code for benchmark #6

Closed
aryoda opened this issue Feb 9, 2018 · 2 comments
Closed

Add source code for benchmark #6

aryoda opened this issue Feb 9, 2018 · 2 comments

Comments

@aryoda
Copy link

aryoda commented Feb 9, 2018

I really appreciate new DB access solutions and benchmarks like yours but I would like see the source code for the benchmark too to play around and reproduce the results.

For example, your are mentioning using DBI::dbWriteTable but DBI is just an interface and the performance depends on DBI driver you are using (e. g. dbConnect(odbc::odbc()... or RODBCDBI::ODBC())...

@martinkabe
Copy link
Owner

martinkabe commented Feb 9, 2018

Below is code I used for performance comparison:

Create data.frame:

data <- data.frame(ID=1:2e6,
                   Name=rep(c("Joseph Karin...","Some another name","Charles von Ried","Stanley Cat...","Oskar-Rotnor"), 4000000),
                   Price=rnorm(2e6),
                   Margin=rep(c(1.5e3, 1e5, 1.24e5, 1.31e6, 1.214e5), 4000000),
                   DateOfDelivery=rep(as.Date(c("2017-12-16","2017-12-15","2017-12-14","2017-12-13","2017-12-12")), 4000000),
                   DateOfRecieve=rep(c("2017-12-16 23:05:01","2017-12-15 15:06:00","2017-12-14 05:15:25",
                                       "2017-12-13 23:00:00","2017-12-12 00:05:01"), 4000000),
                   stringsAsFactors = FALSE)

dbWriteTable

library(dbplyr)
library(dplyr)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
                      Driver = "SQL Server", 
                      Server = "LAPTOP-PCNAME\\SQLEXPRESS", 
                      Database = "Data",
                      Trusted_Connection = "True")

system.time({
  dbWriteTable(conn = con, "DataTable", data, append=F)
})

sqlSave

library(RODBC)
dbhandle <- odbcDriverConnect('driver={SQL Server};server=LAPTOP-PCNAME\\SQLEXPRESS;database=Data;trusted_connection=true')

system.time({
  sqlSave(dbhandle, data, tablename = "DataTable", rownames = F)
})

push_data

library(RSQLS)
cs <- set_connString("LAPTOP-PCNAME\\SQLEXPRESS", "Data")

system.time({
push_data(cs, data, "dbo.DataTable", showprogress = T, append = T)
})

@aryoda
Copy link
Author

aryoda commented Feb 9, 2018

Great, thanks!

@aryoda aryoda closed this as completed Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants