From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | mike bayer <mike_mp(at)zzzcomputing(dot)com>, "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org> |
Subject: | Re: speed concerns with executemany() |
Date: | 2016-12-24 01:23:21 |
Message-ID: | 3404212c-a57c-776d-1ac7-9bb7e16f0bb3@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 12/23/2016 05:09 PM, Daniele Varrazzo wrote:
> On Sat, Dec 24, 2016 at 2:05 AM, Adrian Klaver
> <adrian(dot)klaver(at)aklaver(dot)com> wrote:
>
>> I have to go with Christophe's explanation. They are seeing the effects of
>> 200 separate transactions, though like he stated later this more an
>> assumption then something I have tested.
>
> My wild wild wild assumption is that they have a trigger on the table
> that gets triggered 200 times instead of one.
>
> The only thing I am sure of is that psycopg doesn't use any BEGIN
> specifically in executemany.
I see that now:
In [5]: val_list = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
In [12]: sql = "INSERT INTO psycopg_table VALUES(%s, %s, %s)"
In [16]: con.set_session(autocommit=True)
In [17]: cur = con.cursor()
In [18]: cur.executemany(sql, val_list)
[unknown]-2016-12-23 17:17:10.829 PST-0 LOG: connection received:
host=::1 port=37352
aklaver-2016-12-23 17:17:10.830 PST-0 LOG: connection authorized:
user=aklaver database=production
aklaver-2016-12-23 17:17:35.373 PST-0 LOG: statement: INSERT INTO
psycopg_table VALUES(1, 2, 3)
aklaver-2016-12-23 17:17:35.416 PST-0 LOG: statement: INSERT INTO
psycopg_table VALUES(4, 5, 6)
aklaver-2016-12-23 17:17:35.457 PST-0 LOG: statement: INSERT INTO
psycopg_table VALUES(7, 8, 9)
Yet the data was available immediately in another session without a
explicit COMMIT, so how is psycopg2 committing the INSERTs?
>
>
> -- Daniele
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Christophe Pettus | 2016-12-24 01:37:28 | Re: speed concerns with executemany() |
Previous Message | Daniele Varrazzo | 2016-12-24 01:09:34 | Re: speed concerns with executemany() |