diff --git a/crates/storage-pg/migrations/20240718075125_sessions_active_index.sql b/crates/storage-pg/migrations/20240718075125_sessions_active_index.sql new file mode 100644 index 00000000..212a7a05 --- /dev/null +++ b/crates/storage-pg/migrations/20240718075125_sessions_active_index.sql @@ -0,0 +1,19 @@ +-- Copyright 2024 The Matrix.org Foundation C.I.C. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + + +-- Adds an index on the last_active_at column of the sessions tables +CREATE INDEX "compat_sessions_last_active_at_idx" ON "compat_sessions" ("last_active_at"); +CREATE INDEX "oauth2_sessions_last_active_at_idx" ON "oauth2_sessions" ("last_active_at"); +CREATE INDEX "user_sessions_last_active_at_idx" ON "user_sessions" ("last_active_at");