1
0
Fork 0
mirror of https://github.com/element-hq/synapse.git synced 2025-03-20 23:02:33 +00:00

Add index to sliding sync membership snapshot table, to fix a performance issue. (#18074)

To address a performance problem due to the foreign key on the same
column.

cc @erikjohnston

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
This commit is contained in:
reivilibre 2025-03-18 18:38:18 +00:00 committed by GitHub
parent 4b8dbe22c0
commit 47e295bf3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 1 deletions

1
changelog.d/18074.bugfix Normal file
View file

@ -0,0 +1 @@
Add index to sliding sync membership snapshot table, to fix a performance issue.

View file

@ -1,7 +1,7 @@
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright (C) 2023 New Vector, Ltd
# Copyright (C) 2023, 2025 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -61,6 +61,13 @@ class SlidingSyncStore(SQLBaseStore):
columns=("required_state_id",),
)
self.db_pool.updates.register_background_index_update(
update_name="sliding_sync_membership_snapshots_membership_event_id_idx",
index_name="sliding_sync_membership_snapshots_membership_event_id_idx",
table="sliding_sync_membership_snapshots",
columns=("membership_event_id",),
)
async def get_latest_bump_stamp_for_room(
self,
room_id: str,

View file

@ -0,0 +1,15 @@
--
-- This file is licensed under the Affero General Public License (AGPL) version 3.
--
-- Copyright (C) 2025 New Vector, Ltd
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- See the GNU Affero General Public License for more details:
-- <https://www.gnu.org/licenses/agpl-3.0.html>.
INSERT INTO background_updates (ordering, update_name, progress_json) VALUES
(8901, 'sliding_sync_membership_snapshots_membership_event_id_idx', '{}');