Skip to content
Discussion options

You must be logged in to vote

Two points resolve most of the apparent contradiction.

First, ATTACH ... TYPE postgres does not force every query through one permanent PostgreSQL connection. The extension has its own connection pool and can open multiple PostgreSQL connections, including several for a single parallel table scan. Current controls include pg_connection_limit and the pool settings documented under PostgreSQL connection pooling.

Second, use one DuckDB client context per Python worker:

root = duckdb.connect(...)
root.execute("""
    ATTACH 'host=... dbname=...' AS pg
    (TYPE postgres, READ_ONLY)
""")

def worker(sql, params=()):
    local = root.cursor()
    try:
        return local.execute(sql, params).f…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by evertlammerts
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants