Skip to content

Commit c861856

Browse files
committed
Create missing indexes for all the foreign keys in the database.
1 parent e91ff20 commit c861856

File tree

46 files changed

+427
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+427
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
compat_access_tokens_session_fk
9+
ON compat_access_tokens (compat_session_id);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
compat_refresh_tokens_session_fk
9+
ON compat_refresh_tokens (compat_session_id);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
compat_refresh_tokens_access_token_fk
9+
ON compat_refresh_tokens (compat_access_token_id);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
-- Including the `last_active_at` column lets us effeciently filter in-memory
8+
-- for those sessions without fetching the rows, and without including it in the
9+
-- index btree
10+
CREATE INDEX CONCURRENTLY
11+
compat_sessions_user_fk
12+
ON compat_sessions (user_id)
13+
INCLUDE (last_active_at);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
compat_sessions_user_session_fk
9+
ON compat_sessions (user_session_id);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
-- Redundant with the `compat_sessions_user_fk`
8+
DROP INDEX IF EXISTS compat_sessions_user_id_last_active_at;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
compat_sso_logins_session_fk
9+
ON compat_sso_logins (compat_session_id);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
oauth2_access_tokens_session_fk
9+
ON oauth2_access_tokens (oauth2_session_id);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
oauth2_authorization_grants_session_fk
9+
ON oauth2_authorization_grants (oauth2_session_id);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
CREATE INDEX CONCURRENTLY
8+
oauth2_authorization_grants_client_fk
9+
ON oauth2_authorization_grants (oauth2_client_id);

0 commit comments

Comments
 (0)