mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 14:34:59 -04:00
Replace uses of simple_insert_many with simple_insert_many_values. (#11742)
This should be (slightly) more efficient and it is simpler to have a single method for inserting multiple values.
This commit is contained in:
parent
d70169bf9b
commit
3e0536cd2a
19 changed files with 263 additions and 298 deletions
|
@ -105,8 +105,10 @@ class UserDirectoryBackgroundUpdateStore(StateDeltasStore):
|
|||
GROUP BY room_id
|
||||
"""
|
||||
txn.execute(sql)
|
||||
rooms = [{"room_id": x[0], "events": x[1]} for x in txn.fetchall()]
|
||||
self.db_pool.simple_insert_many_txn(txn, TEMP_TABLE + "_rooms", rooms)
|
||||
rooms = list(txn.fetchall())
|
||||
self.db_pool.simple_insert_many_txn(
|
||||
txn, TEMP_TABLE + "_rooms", keys=("room_id", "events"), values=rooms
|
||||
)
|
||||
del rooms
|
||||
|
||||
sql = (
|
||||
|
@ -117,9 +119,11 @@ class UserDirectoryBackgroundUpdateStore(StateDeltasStore):
|
|||
txn.execute(sql)
|
||||
|
||||
txn.execute("SELECT name FROM users")
|
||||
users = [{"user_id": x[0]} for x in txn.fetchall()]
|
||||
users = list(txn.fetchall())
|
||||
|
||||
self.db_pool.simple_insert_many_txn(txn, TEMP_TABLE + "_users", users)
|
||||
self.db_pool.simple_insert_many_txn(
|
||||
txn, TEMP_TABLE + "_users", keys=("user_id",), values=users
|
||||
)
|
||||
|
||||
new_pos = await self.get_max_stream_id_in_current_state_deltas()
|
||||
await self.db_pool.runInteraction(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue