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

dbWriteTable inserts partial data for large data frames #200

Open
ajzz opened this issue May 11, 2017 · 2 comments
Open

dbWriteTable inserts partial data for large data frames #200

ajzz opened this issue May 11, 2017 · 2 comments

Comments

@ajzz
Copy link

ajzz commented May 11, 2017

DB: MySQL 5.6.27
Package version: RMySQL_0.10.11
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Steps to reproduce:

  1. Write large data frame > 500K rows & 15 columns to table with existing schema (append = TRUE)
  2. Typically 300-400K rows get written, but not the entire data frame. Number of rows written each time are variable.

Functioning workaround:
Batch the write with new connection per batch
eg:

    ## Workaround for MySQL driver issues
    batchsize = 100000
    
    if (nrow(data) >= batchsize) {
      batch <- split(data, 1:nrow(data) %/% batchsize)
    
      op <- lapply(batch, function(x) {
      
      ## Make separate connections for each batch
      conn2 <- RMySQL::dbConnect( ... connectionparams ... )
      RMySQL::dbWriteTable(conn = conn2, 
                           name = tablename, 
                           value = x,
                           append = TRUE,
                           row.names = FALSE)
      DBI::dbDisconnect(conn2)
      
    })
    } else { ... write normally ...}
@ajzz
Copy link
Author

ajzz commented May 20, 2017

Possible causal factor: temp file write fails silently when working directory storage limits are surpassed.

@raggaraluz
Copy link

Is the connection lost after the insert? Just wondering if it is related to #190

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

No branches or pull requests

3 participants