r-dbi / adbc Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
For duckdb, it seems that going through a RecordBatchReader is slower than through data frames. Further investigation is needed.
I've tested various scenarios for 10k rows of flights data: streaming, reading as data frame, writing to parquet files.
library(adbc)
library(duckdb)
#> Loading required package: DBI
library(dbplyr)
library(conflicted)
con <- dbConnect(
adbc(asNamespace("duckdb")$.__NAMESPACE__.$DLLs$duckdb[["path"]], "duckdb_adbc_init")
)
# dbWriteTable() doesn't work yet
flights <- copy_inline(con, nycflights13::flights[1:10000, ])
sql <- flights %>% sql_render()
system.time(dbExecute(con, paste0("CREATE TABLE flights AS ", sql)))
#> user system elapsed
#> 3.438 0.036 3.450
bench::mark(
as.data.frame(dbStreamTable(con, "flights"))[10000:1, ]
)
#> # A tibble: 1 × 6
#> expression min median itr/s…¹
#> <bch:expr> <bch:t> <bch:> <dbl>
#> 1 as.data.frame(dbStreamTable(con, "flights"))[10000:1, ] 32.3ms 32.9ms 30.2
#> # … with 2 more variables: mem_alloc <bch:byt>, `gc/sec` <dbl>, and abbreviated
#> # variable name ¹`itr/sec`
Created on 2022-10-23 with reprex v2.0.2
library(adbc)
library(duckdb)
#> Loading required package: DBI
library(dbplyr)
library(conflicted)
con <- dbConnect(
adbc(asNamespace("duckdb")$.__NAMESPACE__.$DLLs$duckdb[["path"]], "duckdb_adbc_init")
)
# dbWriteTable() doesn't work yet
flights <- copy_inline(con, nycflights13::flights[1:10000, ])
sql <- flights %>% sql_render()
system.time(dbExecute(con, paste0("CREATE TABLE flights AS ", sql)))
#> user system elapsed
#> 3.395 0.035 3.438
bench::mark(
dbReadTable(con, "flights")[10000:1, ]
)
#> # A tibble: 1 × 6
#> expression min median itr/s…¹ mem_a…² gc/se…³
#> <bch:expr> <bch:tm> <bch:> <dbl> <bch:b> <dbl>
#> 1 dbReadTable(con, "flights")[10000:1, ] 29.2ms 30.4ms 32.6 19.5MB 4.34
#> # … with abbreviated variable names ¹`itr/sec`, ²mem_alloc, ³`gc/sec`
Created on 2022-10-23 with reprex v2.0.2
library(adbc)
library(duckdb)
#> Loading required package: DBI
library(dbplyr)
library(arrow)
#> Some features are not enabled in this build of Arrow. Run `arrow_info()` for more information.
#>
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#>
#> timestamp
library(conflicted)
con <- dbConnect(
adbc(asNamespace("duckdb")$.__NAMESPACE__.$DLLs$duckdb[["path"]], "duckdb_adbc_init")
)
# dbWriteTable() doesn't work yet
flights <- copy_inline(con, nycflights13::flights[1:10000, ])
sql <- flights %>% sql_render()
system.time(dbExecute(con, paste0("CREATE TABLE flights AS ", sql)))
#> user system elapsed
#> 3.407 0.034 3.451
bench::mark(
write_dataset(dbStreamTable(con, "flights"), "f.p")
)
#> # A tibble: 1 × 6
#> expression min median itr/se…¹
#> <bch:expr> <bch:tm> <bch:tm> <dbl>
#> 1 write_dataset(dbStreamTable(con, "flights"), "f.p") 35.8ms 36.9ms 26.9
#> # … with 2 more variables: mem_alloc <bch:byt>, `gc/sec` <dbl>, and abbreviated
#> # variable name ¹`itr/sec`
Created on 2022-10-23 with reprex v2.0.2
library(adbc)
library(duckdb)
#> Loading required package: DBI
library(dbplyr)
library(conflicted)
con <- dbConnect(
duckdb::duckdb()
)
# dbWriteTable() doesn't work yet
flights <- copy_inline(con, nycflights13::flights[1:10000, ])
sql <- flights %>% sql_render()
system.time(dbExecute(con, paste0("CREATE TABLE flights AS ", sql)))
#> user system elapsed
#> 3.660 0.038 3.685
bench::mark(
as.data.frame(dbStreamTable(con, "flights"))[10000:1, ]
)
#> # A tibble: 1 × 6
#> expression min median itr/s…¹
#> <bch:expr> <bch:t> <bch:> <dbl>
#> 1 as.data.frame(dbStreamTable(con, "flights"))[10000:1, ] 22.2ms 23ms 43.7
#> # … with 2 more variables: mem_alloc <bch:byt>, `gc/sec` <dbl>, and abbreviated
#> # variable name ¹`itr/sec`
Created on 2022-10-23 with reprex v2.0.2
library(adbc)
library(duckdb)
#> Loading required package: DBI
library(dbplyr)
library(conflicted)
con <- dbConnect(
duckdb::duckdb()
)
# dbWriteTable() doesn't work yet
flights <- copy_inline(con, nycflights13::flights[1:10000, ])
sql <- flights %>% sql_render()
system.time(dbExecute(con, paste0("CREATE TABLE flights AS ", sql)))
#> user system elapsed
#> 3.665 0.034 3.673
bench::mark(
dbReadTable(con, "flights")[10000:1, ]
)
#> # A tibble: 1 × 6
#> expression min median itr/s…¹ mem_a…² gc/se…³
#> <bch:expr> <bch:tm> <bch:> <dbl> <bch:b> <dbl>
#> 1 dbReadTable(con, "flights")[10000:1, ] 12.8ms 13.1ms 75.5 2.3MB 0
#> # … with abbreviated variable names ¹`itr/sec`, ²mem_alloc, ³`gc/sec`
Created on 2022-10-23 with reprex v2.0.2
library(adbc)
library(duckdb)
#> Loading required package: DBI
library(dbplyr)
library(arrow)
#> Some features are not enabled in this build of Arrow. Run `arrow_info()` for more information.
#>
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#>
#> timestamp
library(conflicted)
con <- dbConnect(
duckdb::duckdb()
)
# dbWriteTable() doesn't work yet
flights <- copy_inline(con, nycflights13::flights[1:10000, ])
sql <- flights %>% sql_render()
system.time(dbExecute(con, paste0("CREATE TABLE flights AS ", sql)))
#> user system elapsed
#> 3.629 0.034 3.663
bench::mark(
write_dataset(dbStreamTable(con, "flights"), "f.p")
)
#> # A tibble: 1 × 6
#> expression min median itr/se…¹
#> <bch:expr> <bch:tm> <bch:tm> <dbl>
#> 1 write_dataset(dbStreamTable(con, "flights"), "f.p") 26.1ms 26.7ms 37.2
#> # … with 2 more variables: mem_alloc <bch:byt>, `gc/sec` <dbl>, and abbreviated
#> # variable name ¹`itr/sec`
Created on 2022-10-23 with reprex v2.0.2
Need to install special adbc-18 branch of duckdb. Solution:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.