R: Painfully slow read performance using RODBC & SQL Server R: Painfully slow read performance using RODBC & SQL Server database database

R: Painfully slow read performance using RODBC & SQL Server


I would try RJDBChttp://cran.r-project.org/web/packages/RJDBC/RJDBC.pdf

with these drivers https://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx

library(RJDBC)drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver","/sqljdbc4.jar") con <- dbConnect(drv, "jdbc:sqlserver://server.location", "username", "password")dbGetQuery(con, "select column_name from table")


I would make sure that your R timezone - Sys.setenv(TZ='GMT') set to GMT for example - is same as the time zone of the SQL server from where you are pulling data. It could be that the date column is taking a long time to be interpreted especially if it has a timestamp.

RJDBC will run quicker because it converts date to character and everything else to numeric. RODBC will try to preserve the data type of the SQL table.