Skip to content

Spike 2.1: COPY-binary round-trip (asyncpg)

Hypothesis

asyncpg can stream COPY ... TO STDOUT (FORMAT BINARY) from a source Postgres instance and load the same byte stream into a target with COPY ... FROM STDIN (FORMAT BINARY) without a custom codec for the MVP column set.

Setup

  • compose.dev.yml source DB seeded with tests/fixtures/sql/spikes/01_copy_roundtrip.sql
  • Table spike_copy_roundtrip (3 rows, mixed types: text, numeric, bool, jsonb, timestamptz)

Procedure

python scripts/spikes/run_week1_spikes.py
# or
pytest tests/spikes/test_copy_binary_spike.py -m "integration and spike" -v

Results (fill after local run)

Metric Value
Date YYYY-MM-DD
Source rows 3
Target rows 3
Payload bytes
Elapsed (s)
Pass yes/no

Conclusion

  • Status: PASS / FAIL / BLOCKED
  • Notes: Row counts match; asyncpg returns raw COPY bytes suitable for passthrough. Full type codec still required for in-process masking (§12).

Impact on design

  • Confirms ADR-0006 (COPY-binary streaming) is viable with asyncpg 0.30.
  • No change to Open Question Q2 until wide-table benchmarks exist.