mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-17 13:39:10 -04:00
Use execute_batch instead of executemany in places (#9181)
`execute_batch` does fewer round trips in postgres than `executemany`, but does not give a correct `txn.rowcount` result after.
This commit is contained in:
parent
1fa15b74e0
commit
eee6fcf5fa
3 changed files with 12 additions and 12 deletions
|
@ -267,8 +267,7 @@ class LoggingTransaction:
|
|||
|
||||
self._do_execute(lambda *x: execute_batch(self.txn, *x), sql, args)
|
||||
else:
|
||||
for val in args:
|
||||
self.execute(sql, val)
|
||||
self.executemany(sql, args)
|
||||
|
||||
def execute_values(self, sql: str, *args: Any) -> List[Tuple]:
|
||||
"""Corresponds to psycopg2.extras.execute_values. Only available when
|
||||
|
@ -888,7 +887,7 @@ class DatabasePool:
|
|||
", ".join("?" for _ in keys[0]),
|
||||
)
|
||||
|
||||
txn.executemany(sql, vals)
|
||||
txn.execute_batch(sql, vals)
|
||||
|
||||
async def simple_upsert(
|
||||
self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue