Giter VIP home page Giter VIP logo

adbc's People

Contributors

indrajeetpatil avatar krlmlr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

adbc's Issues

Investigate weak performance

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.

adbc + duckdb

Stream

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

Read

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

Parquet

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

duckdb + DBI classic

Stream

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

Read

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

Parquet

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

Fix GitHub Actions

Need to install special adbc-18 branch of duckdb. Solution:

  • create fork for adbc branch in r-dbi organization
  • register with R-universe
  • install from there

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.