duckdb / postgres_scanner

https://duckdb.org/docs/extensions/postgres
MIT License
227 stars 36 forks source link

Fix #156 - avoid sharing the same connection over different scans #171

Closed Mytherin closed 8 months ago

Mytherin commented 8 months ago

Fixes #156

The issue essentially occurs when we are streaming multiple Postgres results through multiple different scans using the same connection. This issue is unique to the new ATTACH method as the attach method has a "main connection" - whereas the postgres_scan methods would simply always open new connections.

We solve this issue by doing the following:

This solves the issue and allows us to re-use the main connection as much as possible, while being correct in all cases (both with and without the optimizer run).

This PR also turns the connection cache back on by default and changes the setting to pg_connection_cache (instead of pg_experimental_connection_cache). In addition, we also add cardinality measurement to the scan (PostgresScanCardinality).