From bf2ad55b5ce8229fc62b5f8709eae91ba57366d3 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Thu, 8 Jan 2026 19:01:28 +0100 Subject: [PATCH] Speed up access token cleanup with an index --- ...20260108175627_oauth_access_tokens_revoked_at_idx.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 crates/storage-pg/migrations/20260108175627_oauth_access_tokens_revoked_at_idx.sql diff --git a/crates/storage-pg/migrations/20260108175627_oauth_access_tokens_revoked_at_idx.sql b/crates/storage-pg/migrations/20260108175627_oauth_access_tokens_revoked_at_idx.sql new file mode 100644 index 000000000..aa119ec23 --- /dev/null +++ b/crates/storage-pg/migrations/20260108175627_oauth_access_tokens_revoked_at_idx.sql @@ -0,0 +1,9 @@ +-- no-transaction +-- Copyright 2026 Element Creations Ltd. +-- +-- SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +-- Please see LICENSE in the repository root for full details. + +-- This adds an index on the revoked_at field on oauth2_access_tokens to speed up cleaning them up +CREATE INDEX CONCURRENTLY IF NOT EXISTS oauth_access_tokens_revoked_at_idx + ON oauth2_access_tokens (revoked_at) WHERE revoked_at IS NOT NULL;