Consecutive Inserts Freeze Execution of Psycopg3 - Mailing list psycopg

From Michael P. McDonnell
Subject Consecutive Inserts Freeze Execution of Psycopg3
Date
Msg-id CAHmCLHrztOYi=uLqc6jKrytz5=e4ZKhYP1LTyLfTi-KGC1pR9w@mail.gmail.com
Whole thread Raw
Responses Re: Consecutive Inserts Freeze Execution of Psycopg3  (Adrian Klaver <adrian.klaver@aklaver.com>)
List psycopg
Python 3.10.6
psycopg library 3.1.8

Running consecutive inserts sourced in files.
All inserts are of the same format:

INSERT INTO _____ (field1, field2, field3)
SELECT field1, field2, field3 FROM ____, Join ___, join ___ etc...

The code I've written is this:

for qi in range(qlen):
            query = queries[qi]
            qparams = params[qi]
            with self.connection.cursor() as conn:
                conn.execute(query, qparams)

When I run the queries in dbeaver - the first query takes 120s (it's 1.9M rows), the second query takes 2s (7000 rows).
When I run the queries in python - it freezes on the second query.

Any guidance on how to attack this would be awesome as I have re-written my code a dozen times and am just slinging mud to see what sticks.

psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: Escape Python to `json[]` for `COPY FROM` PostgreSQL insertion?
Next
From: Adrian Klaver
Date:
Subject: Re: Consecutive Inserts Freeze Execution of Psycopg3