0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-13 21:43:22 +01:00

Speed up persisting redacted events (#10756)

This commit is contained in:
Erik Johnston 2021-09-06 10:14:07 +01:00 committed by GitHub
parent 1ca70fd312
commit 2ca0d64854
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

1
changelog.d/10756.misc Normal file
View file

@ -0,0 +1 @@
Minor speed ups when joining large rooms over federation.

View file

@ -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()