mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-17 13:20:27 -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
|
@ -432,14 +432,21 @@ class DeviceInboxWorkerStore(SQLBaseStore):
|
|||
self.db_pool.simple_insert_many_txn(
|
||||
txn,
|
||||
table="device_federation_outbox",
|
||||
keys=(
|
||||
"destination",
|
||||
"stream_id",
|
||||
"queued_ts",
|
||||
"messages_json",
|
||||
"instance_name",
|
||||
),
|
||||
values=[
|
||||
{
|
||||
"destination": destination,
|
||||
"stream_id": stream_id,
|
||||
"queued_ts": now_ms,
|
||||
"messages_json": json_encoder.encode(edu),
|
||||
"instance_name": self._instance_name,
|
||||
}
|
||||
(
|
||||
destination,
|
||||
stream_id,
|
||||
now_ms,
|
||||
json_encoder.encode(edu),
|
||||
self._instance_name,
|
||||
)
|
||||
for destination, edu in remote_messages_by_destination.items()
|
||||
],
|
||||
)
|
||||
|
@ -571,14 +578,9 @@ class DeviceInboxWorkerStore(SQLBaseStore):
|
|||
self.db_pool.simple_insert_many_txn(
|
||||
txn,
|
||||
table="device_inbox",
|
||||
keys=("user_id", "device_id", "stream_id", "message_json", "instance_name"),
|
||||
values=[
|
||||
{
|
||||
"user_id": user_id,
|
||||
"device_id": device_id,
|
||||
"stream_id": stream_id,
|
||||
"message_json": message_json,
|
||||
"instance_name": self._instance_name,
|
||||
}
|
||||
(user_id, device_id, stream_id, message_json, self._instance_name)
|
||||
for user_id, messages_by_device in local_by_user_then_device.items()
|
||||
for device_id, message_json in messages_by_device.items()
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue