Open wowka1319 opened 1 year ago
I don't think FROM VALUES
buys you anything here, and it could actually be slightly worse.
I know the second is performed as one request
Not quite simple as that. executemany()
is a pipelined operation, and so while the query is parsed and prepared only once, it is executed as many times as there are items in the users
iterable. However, since asyncpg does not wait for the result of each execution and continues pumping the arguments this is almost as fast as sending the entire argument set at once.
The first is cleaner. But I worry about performance. I know the second is performed as one request. But the first is the same?
Is there any reason to use the second way?