public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter J. Holzer <[email protected]>
To: [email protected]
Subject: Re: How batch processing works
Date: Sun, 22 Sep 2024 21:36:12 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAKna9VY2v0XsDberzbJXZ4MqEW1RUtD0L_Mis_vrgEQWZgH0gg@mail.gmail.com>
	<[email protected]>
	<CAKna9Vbt1VJu7Oa8FTWasgby+-kJn7omOhbfmWzkdpVwBiqNzQ@mail.gmail.com>
	<[email protected]>
	<[email protected]>

On 2024-09-21 12:15:44 -0700, Adrian Klaver wrote:
> FYI, this is less of problem with psycopg(3) and pipeline mode:
> 
[...]
> with db.pipeline():
>     for i in range(1, num_inserts+1):
>         csr.execute("insert into parent_table values(%s, %s)", (i, 'a'))
>         if i % batch_size == 0:
>             db.commit()
> db.commit()
[...]
> 
> For remote to a database in another state that took the  time from:
> 
> Method 2: Individual Inserts with Commit after 50  Rows: 2.42e+02 seconds
> 
> to:
> 
> Method 2: Individual Inserts(psycopg3 pipeline mode) with Commit after 50
> Rows: 9.83 seconds

Very cool. I'll keep that in mind.

I've been using psycopg 3 for newer projects, but for throwaway code
I've been sticking to psycopg2, simply because it's available from the
repos of all my usual distributions. It's now in both Debian and Ubuntu,
so that will change.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | [email protected]         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"


Attachments:

  [application/pgp-signature] signature.asc (833B, 2-signature.asc)
  download

view thread (7+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: How batch processing works
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox