-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
Milestone
Description
I experiment writing a table (a tibble: 34,951 x 52) into a MySQL database (5.6):
MySQL database on localhost (same computer):
- RMySQL = 3.4s
- RMariaDB = 8s
remote MySQL database:
- RMySQL = 11s
- RMariaDB : R still running after 5mn, i have to kill it
remote MySQL database with a reduced table (586 x 52):
- RMySQL = 0.4s
- RMariaDB = 16s
library(tidyverse)
library(readxl)
library(RMySQL)
library(RMariaDB)
library(curl)
urlhebtour <- "https://insee.fr/fr/statistiques/fichier/2021703/base-cc-tourisme-2020.zip"
xlsfile <- unzip( curl_download( urlhebtour, "temp.zip" ) )
dt <- read_excel( xlsfile, sheet = "COM", skip = 5 ) %>% select(-LIBGEO)
# RMySQL test on localhost
db_cred = list( drv = MySQL(), host="localhost", dbname="donstat", user="xxx", password="xxx" )
mycon <- exec( "dbConnect", !!!db_cred )
system.time( dbWriteTable( mycon, value = dt, name = "tourism2020",
overwrite = TRUE, row.names = FALSE ) )
# RMySQL 3.4s
tbl(mycon, "tourism2020") %>% collect()
# A tibble: 34,951 x 52
dbDisconnect(mycon)
# RMariaDB test on localhost
db_cred <- list( drv = MariaDB(), host="localhost", dbname="donstat", user="xxx", password="xxx" )
mycon <- exec( "dbConnect", !!!db_cred )
system.time( dbWriteTable( mycon, value = dt, name = "tourism2020",
overwrite = TRUE, row.names = FALSE ) )
# RMariaDB 8s
tbl(mycon, "tourism2020") %>% collect()
# A tibble: 34,951 x 52With a remote database and RMariaDB, it doesn't end
So let's try with a reduced tibble (=> 586 rows)
system.time( dbWriteTable( mycon, value = dt %>% filter(DEP == "31"), name = "tourism2020", overwrite = TRUE, row.names = FALSE ) )
# RMySQL = 0.4s
# RMariaDB = 16szenggyu and GitHunter0GitHunter0