How long does it take to move a query result from a data service into another program's memory? We moved the same results six ways into a fresh client process and timed each one:
- CSV text over HTTP from an Apache DataFusion 55.0.0 service
- Arrow Flight, one stream, from the same service
- Arrow Flight, four streams
- JDBC (Java) from PostgreSQL 18.7
- A Python DB-API driver (psycopg2) from PostgreSQL
- ADBC from PostgreSQL (binary COPY straight into Arrow arrays)
The setup
-
Data: TPC-H
lineitem(6,001,215 rows) and the NYC taxi trips of January 2024 (2,964,624 rows). - Queries: seven, from 4 rows (TPC-H Q1) to the whole table.
- Finish line: every run ends with the whole result as typed columns in the client's memory, not just bytes received.
- Measured: transfer time, client and service CPU, memory, and bytes on the wire.
- Answer check: all 251 runs matched a reference computed by DuckDB from the Parquet files.
Client and services ran on one standard laptop over the loopback interface. This compares the exchange paths, not network speed.
Results: the whole lineitem table
Mean of 3 runs, 6,001,215 rows into client memory:
| Path | Time | Client CPU (s) |
|---|---|---|
| Arrow Flight, 4 streams | 560 ms | 2.41 |
| Arrow Flight, 1 stream | 2.41 s | 2.84 |
| CSV over HTTP | 4.56 s | 5.67 |
| ADBC (PostgreSQL) | 6.18 s | 2.68 |
| JDBC (Java) | 10.7 s | 18.17 |
| DB-API (psycopg2) | 23.3 s | 18.80 |
Over the four large results, as geometric means relative to one Flight stream: CSV 2.6x slower, ADBC 3.9x, JDBC 5.9x, psycopg2 12.1x.
Arrow was not smaller on the wire
We expected Arrow to win by sending fewer bytes. It did not:
- Per lineitem row: CSV 135 bytes, Arrow Flight 137, JDBC and psycopg2 180, ADBC 188.
- On the six numeric columns, CSV was even smaller than Arrow (35 vs 48 bytes per row). Arrow sends its in-memory layout, a fixed 8 bytes per number, while short numbers as text take fewer bytes.
Arrow's speed comes from not having to parse. The row and text paths spend their CPU converting every value: parsing text, building Java or Python objects, then building columns. The Arrow paths hand over buffers.
You can get Arrow without changing the database
ADBC read the same PostgreSQL tables as JDBC and psycopg2, but through binary COPY into Arrow arrays:
- 6.18 s against 10.7 s (JDBC) and 23.3 s (psycopg2)
- 2.68 s of client CPU against 18.17 s and 18.80 s
Small results are a different story
For about 10 thousand rows, Flight took 56 ms and CSV 68 ms, but all three PostgreSQL paths took about 600-740 ms. Almost all of that is fixed cost: a PostgreSQL connection starts a new server process on Windows, and the drivers read type information first.
A simple fitted model (time = fixed cost + rows x per-row cost) shows it clearly:
| Path | Fixed cost | Per row |
|---|---|---|
| Arrow Flight, 1 stream | 58 ms | 0.39 us |
| CSV over HTTP | 54 ms | 0.75 us |
| ADBC (PostgreSQL) | 589 ms | 0.93 us |
| JDBC (Java) | 614 ms | 1.69 us |
| DB-API (psycopg2) | 597 ms | 3.78 us |
For TPC-H Q1 (4 rows), Flight took 103 ms and PostgreSQL 1.70-1.83 s, because PostgreSQL itself needed 1.48 s for the aggregation. For tiny results, the engine decides, not the exchange format.
What did not work as expected
We varied the record-batch size on one Flight stream (2,048 to 131,072 rows). The times jumped around (1.16 s to 2.41 s for lineitem) without a clear direction, and DataFusion's default of 8,192 rows was the slowest for the text-heavy table. Four streams at 560 ms beat every batch size on one stream.
What we would tell a student
- Measure "into typed columns", not "bytes received". Conversion is where the time goes.
- Separate fixed cost from per-row cost. Small and large results rank the paths differently.
- Try ADBC before replacing a database. Columnar transfer from PostgreSQL gave most of the CPU saving.
- Check every answer against an independent reference. All 251 runs matched DuckDB.
- Know what was not tested: two machines over a real network, ODBC (client written, not run) and Arrow Flight SQL.
Full project, report and video: Columnar Data Exchange: Arrow Flight versus JDBC and CSV - ProTechSC Academy.
We guide final-year and PhD research projects in engineering, AI and big data. WhatsApp +91 97907 09424.
Top comments (0)