Skip to content

Pull materialized CDCs through the engine again for arrow conversion with a live connection / transaction#495

Open
evertlammerts wants to merge 3 commits into
duckdb:v1.5-variegatafrom
evertlammerts:feat/arrow-promote-to-relation
Open

Pull materialized CDCs through the engine again for arrow conversion with a live connection / transaction#495
evertlammerts wants to merge 3 commits into
duckdb:v1.5-variegatafrom
evertlammerts:feat/arrow-promote-to-relation

Conversation

@evertlammerts

@evertlammerts evertlammerts commented Jun 12, 2026

Copy link
Copy Markdown
Member

We should not have custom paths for duckdb -> arrow conversion for already executed results. Instead, we can feed the materialized column data collection back into duckdb, and let it create either a streaming result, which we can wrap in an arrow stream wrapper, or an arrow collector for eagerly materialized arrow arrays. This way we always have a live client context and transaction around when we create arrow output.

Nice side effect: arrow_c_stream uses 50% less memory with this fix. Performance on other paths is largely the same:

  ┌─────────────────────────────────────┬───────┬──────┬───────┬───────┬───────┬──────┐
  │                path                 │ base  │ fix  │ base  │ fix   │ base  │ fix  │
  │                                     │  CPU  │ CPU  │ wall  │ wall  │  mem  │ mem  │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ rel.to_arrow_table() (unchanged —   │ 264   │ 246  │ 49 ms │ 40 ms │ 856   │ 857  │
  │ control)                            │ ms    │ ms   │       │       │ MB    │ MB   │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ rel.pl()                            │ 325   │ 355  │ 76 ms │ 133   │ 783   │ 777  │
  │                                     │ ms    │ ms   │       │ ms    │ MB    │ MB   │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ rel.__arrow_c_stream__()            │ 249   │ 191  │ 50 ms │ 179   │ 618   │ 286  │
  │                                     │ ms    │ ms   │       │ ms    │ MB    │ MB   │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ rel.execute();                      │ 251   │ 305  │ 143   │ 169   │ 625   │ 626  │
  │ rel.__arrow_c_stream__()            │ ms    │ ms   │ ms    │ ms    │ MB    │ MB   │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ rel.to_arrow_reader()               │ 183   │ 174  │ 170   │ 165   │ 128   │ 125  │
  │                                     │ ms    │ ms   │ ms    │ ms    │ MB    │ MB   │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ con.execute(q).to_arrow_table()     │ 221   │ 189  │ 207   │ 177   │ 551   │ 551  │
  │                                     │ ms    │ ms   │ ms    │ ms    │ MB    │ MB   │
  ├─────────────────────────────────────┼───────┼──────┼───────┼───────┼───────┼──────┤
  │ con.execute(q).to_arrow_reader()    │ 181   │ 172  │ 171   │ 162   │ 131   │ 125  │
  │                                     │ ms    │ ms   │ ms    │ ms    │ MB    │ MB   │
  └─────────────────────────────────────┴───────┴──────┴───────┴───────┴───────┴──────┘

@evertlammerts evertlammerts changed the title Pull materialized CDCs through the engine again for arrow conversion … Pull materialized CDCs through the engine again for arrow conversion with a live connection / transaction Jun 12, 2026
@evertlammerts evertlammerts marked this pull request as ready for review June 12, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant