Skip to content

Instantly share code, notes, and snippets.

@leeogrady
Created June 27, 2018 03:03
Show Gist options
  • Save leeogrady/a468b8f65f8546e38e2480aa2a152a0e to your computer and use it in GitHub Desktop.
Save leeogrady/a468b8f65f8546e38e2480aa2a152a0e to your computer and use it in GitHub Desktop.

Just before Log Ship

> t1 <- Sys.time()
> query <- paste0("SELECT TOP 20000 ObservationDate, * 
+                 FROM ValueHolder WHERE ObservationDate IS NOT NULL")
> 
> data <- data.table(
+   sqlQuery(EBConnection,  query = query)
+ )
> t2 <- Sys.time()
> 
> cat(paste0("Time taken to query E-Brida for culls ",t2-t1, " seconds\n"))
Time taken to query E-Brida for culls 6.80851101875305 seconds
> data[,.N]
[1] 511

This contains 511 rows of data.

After log ship without re-login

> t1 <- Sys.time()
> query <- paste0("SELECT TOP 20000 ObservationDate, * 
+                 FROM ValueHolder WHERE ObservationDate IS NOT NULL")
> 
> data2 <- data.table(
+   sqlQuery(EBConnection,  query = query)
+ )
> t2 <- Sys.time()
> 
> cat(paste0("Time taken to query E-Brida for culls ",t2-t1, " seconds\n"))
Time taken to query E-Brida for culls 0.0633997917175293 seconds
> data2[,.N] 
[1] 3

This contains 3 rows of mssql errors relating to not being logged in

With enough time to exec

> EBConnection <-
+   odbcConnect("EBrida Test", "**********", "*********")
> 
> t1 <- Sys.time()
> query <- paste0("SELECT TOP 20000 ObservationDate, * 
+                 FROM ValueHolder WHERE ObservationDate IS NOT NULL")
> 
> data4 <- data.table(
+   sqlQuery(EBConnection,  query = query)
+ )
Warning message:
closing unused RODBC handle 1 
> t2 <- Sys.time()
> 
> cat(paste0("Time taken to query E-Brida for culls ",t2-t1, " seconds\n"))
Time taken to query E-Brida for culls 8.767496027493519 seconds
> data4[,.N] 
[1] 20000

This contains the 20,000 rows of data expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment