diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-11-02 09:41:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 09:41:00 -0400 |
commit | 0afbef30cfb28fbee09989b0a089c86352126ad2 (patch) | |
tree | 019016caf5d49572aa85bc04583b03dcfe9ac69d | |
parent | Bump twisted from 23.8.0 to 23.10.0 (#16588) (diff) | |
download | synapse-0afbef30cfb28fbee09989b0a089c86352126ad2.tar.xz |
Use simple_select_many_txn in event persistance code. (#16585)
Just to standardize on the normal helpers, it might also have a slight perf improvement on PostgreSQL which will now use `ANY (?)` instead of `IN (?, ?, ...)`.
-rw-r--r-- | changelog.d/16585.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/events.py | 16 |
2 files changed, 12 insertions, 5 deletions
diff --git a/changelog.d/16585.misc b/changelog.d/16585.misc new file mode 100644 index 0000000000..01f3ecc843 --- /dev/null +++ b/changelog.d/16585.misc @@ -0,0 +1 @@ +Use standard SQL helpers in persistence code. \ No newline at end of file diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py index 3c1492e3ad..b74ff1c498 100644 --- a/synapse/storage/databases/main/events.py +++ b/synapse/storage/databases/main/events.py @@ -1350,13 +1350,19 @@ class PersistEventsStore: PartialStateConflictError: if attempting to persist a partial state event in a room that has been un-partial stated. """ - txn.execute( - "SELECT event_id, outlier FROM events WHERE event_id in (%s)" - % (",".join(["?"] * len(events_and_contexts)),), - [event.event_id for event, _ in events_and_contexts], + rows = cast( + List[Tuple[str, bool]], + self.db_pool.simple_select_many_txn( + txn, + "events", + "event_id", + [event.event_id for event, _ in events_and_contexts], + keyvalues={}, + retcols=("event_id", "outlier"), + ), ) - have_persisted = dict(cast(Iterable[Tuple[str, bool]], txn)) + have_persisted = dict(rows) logger.debug( "_update_outliers_txn: events=%s have_persisted=%s", |