Skip to content

dbAppendTable is slow while dbWriteTable is fast #306

Description

@gaborcsardi

dbAppendTable() is very slow on a file. It is fast for the in-memory DB.

tab <- pkgcache::meta_cache_list()

## Remove the list columns
tab <- tab[, !sapply(tab, is.list)]
dim(tab)
#> [1] 35359    31

con <- DBI::dbConnect(RSQLite::SQLite(), tempfile(), create = TRUE)
system.time(DBI::dbWriteTable(con, "pkgs", tab))
#>    user  system elapsed 
#>   0.162   0.043   0.211
dim(DBI::dbReadTable(con, "pkgs"))
#> [1] 35359    31
rm(con)

con2 <- DBI::dbConnect(RSQLite::SQLite(), tempfile(), create = TRUE)
DBI::dbCreateTable(con2, "pkgs", tab)
dim(DBI::dbReadTable(con2, "pkgs"))
#> [1]  0 31
system.time(DBI::dbAppendTable(con2, "pkgs", tab))
#>    user  system elapsed 
#>   1.122  11.886  15.088
dim(DBI::dbReadTable(con2, "pkgs"))
#> [1] 35359    31

Created on 2019-12-23 by the reprex package (v0.3.0)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions