Add missing index to `access_tokens` table (#17045)

This was causing sequential scans when using refresh tokens.
This commit is contained in:
Erik Johnston 2024-04-04 11:05:40 +01:00 committed by GitHub
parent 51776745b9
commit 31122b71bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

1
changelog.d/17045.misc Normal file
View File

@ -0,0 +1 @@
Improve database performance by adding a missing index to `access_tokens.refresh_token_id`.

View File

@ -2266,6 +2266,13 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore):
):
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
)