diff options
author | Erik Johnston <erik@matrix.org> | 2021-09-06 10:14:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-06 10:14:07 +0100 |
commit | 2ca0d64854b0d369785f1cb76915a480df445792 (patch) | |
tree | 30c7dd9984dc7bac7d8c946091ca4504024711e6 | |
parent | Allow room creator to send MSC2716 related events in existing room versions (... (diff) | |
download | synapse-2ca0d64854b0d369785f1cb76915a480df445792.tar.xz |
Speed up persisting redacted events (#10756)
-rw-r--r-- | changelog.d/10756.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/events.py | 22 |
2 files changed, 12 insertions, 11 deletions
diff --git a/changelog.d/10756.misc b/changelog.d/10756.misc new file mode 100644 index 0000000000..3b7acff03f --- /dev/null +++ b/changelog.d/10756.misc @@ -0,0 +1 @@ +Minor speed ups when joining large rooms over federation. diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py index c0ff4c0633..f07e288056 100644 --- a/synapse/storage/databases/main/events.py +++ b/synapse/storage/databases/main/events.py @@ -1385,18 +1385,18 @@ class PersistEventsStore: # If we're persisting an unredacted event we go and ensure # that we mark any redactions that reference this event as # requiring censoring. - sql = "UPDATE redactions SET have_censored = ? WHERE redacts = ?" - txn.execute_batch( - sql, - ( - ( - False, - event.event_id, - ) - for event, _ in events_and_contexts - if not event.internal_metadata.is_redacted() - ), + unredacted_events = [ + event.event_id + for event, _ in events_and_contexts + if not event.internal_metadata.is_redacted() + ] + sql = "UPDATE redactions SET have_censored = ? WHERE " + clause, args = make_in_list_sql_clause( + self.database_engine, + "redacts", + unredacted_events, ) + txn.execute(sql + clause, [False] + args) state_events_and_contexts = [ ec for ec in events_and_contexts if ec[0].is_state() |