`dbGetQueryArrow()` is several times slower than `dbGetQuery()` and does not stream
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- postgres, postgresql, r
- 領域
- database, performance
調査の方向性
Start with DBI’s default methods dbFetchArrowChunk() and dbFetchArrow() named in the issue, then read the coordinated RPostgres pull request #631 for the native Arrow approach. Benchmark against dbGetQuery() and check batch production and stream behavior after dbClearResult(). Done means fetching is comparable in speed, batches are produced as consumed, and the stream lifetime is decided.
索引モデルが issue の本文から書いたものです。
説明
Fetching one million rows of (int, text, numeric) with dbGetQueryArrow() takes about three times as long as dbGetQuery() and yields 3907 batches of 256 rows. All batches are fetched before the stream is returned, so memory use is that of the whole result and nothing is streamed. The returned stream is also detached from the result set and stays readable after dbClearResult().
Location: DBI default methods. dbFetchArrowChunk() fetches 256 rows per chunk through dbFetch() and converts each data frame with nanoarrow, and dbFetchArrow() collects every chunk into a list before wrapping it in basic_array_stream().
Reprex against the CRAN release (main at 41cd4be gives comparable timings: 0.73 s and 2.41 s elapsed):
Sys.setenv(PGHOST = "localhost", PGPORT = "5432", PGUSER = "runner", PGPASSWORD = "test123", PGDATABASE = "testdb")
library(DBI)
con <- dbConnect(RPostgres::Postgres())
q <- "SELECT i, i::text AS s, i * 1.5 AS f FROM generate_series(1, 1000000) i"
system.time(dbGetQuery(con, q))
#> user system elapsed
#> 0.608 0.049 0.707
system.time(s <- dbGetQueryArrow(con, q))
#> user system elapsed
#> 2.164 0.042 2.256
# Expected: comparable to dbGetQuery()
k <- 0
while (!is.null(s$get_next())) k <- k + 1
k
#> [1] 3907
# Expected: a few large batches, produced while the stream is consumed
dbGetQuery(con, "SHOW server_version")
#> server_version
#> 1 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1)
dbDisconnect(con)
as.data.frame(sessioninfo::package_info(c("RPostgres", "DBI", "nanoarrow"), dependencies = FALSE))[c("package", "ondiskversion", "source")]
#> package ondiskversion source
#> DBI DBI 1.3.0 RSPM
#> nanoarrow nanoarrow 0.9.0 RSPM
#> RPostgres RPostgres 1.4.10 RSPM (R 4.5.0)
Created on 2026-11-29 with reprex v2.1.1
- fix
- benchmark
- decide the lifetime of the returned stream relative to the result set
Severity: medium (proposed, Kirill may change). Performance and memory.
Native Arrow support is coordinated in https://github.com/r-dbi/RPostgres/pull/631 and is expected to fix this by construction, since the native fetch builds Arrow batches directly from libpq results; the stream lifetime is an open question there.
- 主要言語
- R
- スター
- 345
- フォーク
- 81
- 平均マージ
- 8時間 21分
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
r-dbi/RPostgres のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
Dates and timestamps outside years 0001 to 9999, and `infinity`, are read as garbage, with a probable out-of-bounds read対応中かも @krlmlr が今日担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
r-dbi/RPostgres の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vincentarelbundock/xtx#11 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
ichirio/rtfreporter#1166 ·
メンテナーはふだん 1 日以内に返信