duckdb / postgres_scanner

MIT License
195 stars 35 forks source link

Feature request: transaction isolation across multiple queries to snapshot multiple tables #141

Closed tomtaylor closed 7 months ago

tomtaylor commented 7 months ago

We use duckdb to copy from multiple Postgres tables, against a database that's always moving. It would be really nice if we could open a transaction that would be shared between multiple postgres_scan calls, so we can take a consistent snapshot.

The way postgres_scan takes a transaction and shares that between multiple connections to scan a table is smart, and maybe it would be possible to extend that to work across multiple queries, so we can optionally have a READ COMMITTED view of all the Postgres tables in a duckdb session?

Mytherin commented 7 months ago

You can do exactly that already using the new ATTACH syntax:

ATTACH 'dbname=postgresscanner' AS postgres_db (TYPE postgres);
USE postgres_db;
BEGIN;
SELECT * FROM postgres_db.tbl1;
...
COMMIT;
tomtaylor commented 7 months ago

Oh, amazing! Thanks!