library(dplyr) library(eutradeflows) # To compile this document, run the following at an R prompt: # rmarkdown::render("~/R/eutradeflows/docs/mysql.Rmd") knitr::opts_chunk$set(echo = TRUE) con <- RMariaDB::dbConnect(RMariaDB::MariaDB(), dbname = "tradeflows")
productpattern <- 44079998 tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode %like% productpattern & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
productpattern <- "44079998" tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode %like% productpattern & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
productpattern <- "44079998" tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode == productpattern & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
productpattern <- "44079998" tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode %in% productpattern & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
The addproreppar() function add product description, reporter and partner to the querried data.
The explain shows "ALL" meaning that it will use a full table scan.
swdcodes <- classificationimm$productcode[classificationimm$productimm=="Sawn: softwood"] tableread <- "vld_comext_monthly" periodstart <- 201500 remotequery <- tbl(con, tableread) %>% filter(productcode %in% swdcodes & period > periodstart) explain(remotequery) system.time(dtf <- collect(remotequery))
swdcodes <- classificationimm$productcode[classificationimm$productimm=="Sawn: softwood"] tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode %in% swdcodes & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
productpattern <- "440799%" tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode %like% productpattern & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
productpattern <- "440799%" tableread <- "vld_comext_monthly" periodstart <- 201500 system.time(dtf <- tbl(con, tableread) %>% filter(productcode %like% productpattern & period > periodstart) %>% addproreppar2tbl(con,.) %>% collect())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.