Skip to content

Commit

Permalink
Add missing index to access_tokens table (#17045)
Browse files Browse the repository at this point in the history
This was causing sequential scans when using refresh tokens.
  • Loading branch information
erikjohnston committed Apr 4, 2024
1 parent 5177674 commit 31122b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/17045.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve database performance by adding a missing index to `access_tokens.refresh_token_id`.
7 changes: 7 additions & 0 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,13 @@ def __init__(
):
super().__init__(database, db_conn, hs)

self.db_pool.updates.register_background_index_update(
update_name="access_tokens_refresh_token_id_idx",
index_name="access_tokens_refresh_token_id_idx",
table="access_tokens",
columns=("refresh_token_id",),
)

self._ignore_unknown_session_error = (
hs.config.server.request_token_inhibit_3pid_errors
)
Expand Down

0 comments on commit 31122b7

Please sign in to comment.