Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forgotten schema delta #17054

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/17054.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`.
14 changes: 7 additions & 7 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,13 @@ def __init__(
unique=False,
)

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",),
)

async def _background_update_set_deactivated_flag(
self, progress: JsonDict, batch_size: int
) -> int:
Expand Down Expand Up @@ -2266,13 +2273,6 @@ 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
15 changes: 15 additions & 0 deletions synapse/storage/schema/main/delta/84/04_access_token_index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- This file is licensed under the Affero General Public License (AGPL) version 3.
--
-- Copyright (C) 2023 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
(8404, 'access_tokens_refresh_token_id_idx', '{}');