Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBatch executemany #295
Batch executemany #295
Conversation
|
Other than the transaction status check, LGTM! Thanks! |
|
Update - I've met a racing condition issue during fixing tests. Trying to find time to fix that. |
|
Hey @fantix! Are you still working on this? |
|
Hi! Yes I’m trying to find some time to fix the racing issue, sorry for the delay! |
|
Working on this now - rebased and I'll review the changes, and deal with the racing issue. |
f62a347
to
06b412b
|
Sorry for the delay! This PR is updated now. Benchmark shows the improvement is consistent. I've also added a diagram to explain the details. |
46ecc07
to
6c206e9
|
@fantix The |
|
Got it, thanks a lot! |
|
curious: what is missing to make this accepted? |
|
In awaiting for the PR to be merged, here is a neat trick to get some performances in bulk upsert: credits to Schinckel It consists in:
|
|
Is there a reason it doesn't get merged? |
|
@elprans any chance this can get merged in after the conflict in asyncpg/protocol/protocol.pyx is fixed? |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Refs #289, this is a rewrite of
bind_execute_many():writelines()once flow control turns green.SYNCat the very last - making use of the implicit transaction for the whole call toexecutemany().Support async iterable.executemany()to prepared statement.test_server_failure_during_writesis failing on Windowstest_timeout (test_execute.TestExecuteMany)This is a breaking change due to the implicit transaction.
The 3-level infinite loop keeps filling buffers and send them under flow control, the only exit is raising
StopIterationwith 3 possible values:Truemeans there was data sent in the last loopFalsemeans the last loop sent nothingexceptionmeans the data source raised an exceptionPlease note, during the loop, if server-side error is detected before exhausting the data source, it is also considered as
StopIteration(True), ending the process early with aSYNC_MESSAGE.(I wrote a post about the details of implicit transaction.)
UPDATED - pgbench results of inserting 1000 rows per query with
executemany()on Python 3.6 of 2.2GHz 2015 MacBook Air (best out of 5 runs):asyncpg 0.18.2
This PR:
Most branches are covered by tests, overall coverage 85% (1352 miss) -> 85% (1356 miss).