From 6c2f90774d37a12648f5bfbcdaa8eedc15c095c4 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg Date: Tue, 13 Jan 2026 14:45:52 +0100 Subject: [PATCH] Speed up client and authorization lookup with database indexes During a normal OIDC login workflow (authentication/consent, code exchange, and user info lookup), that results in SQL queries filtering on columns that are now indexed. Before it used to table scan which was extremely slow. --- src/main/resources/db/migration/V7__database_indexes.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/resources/db/migration/V7__database_indexes.sql diff --git a/src/main/resources/db/migration/V7__database_indexes.sql b/src/main/resources/db/migration/V7__database_indexes.sql new file mode 100644 index 0000000..a52b12e --- /dev/null +++ b/src/main/resources/db/migration/V7__database_indexes.sql @@ -0,0 +1,7 @@ +ALTER TABLE oauth2_authorization_consent + ADD INDEX IF NOT EXISTS I_authorization_consent_registered_client_principal (registered_client_id, principal_name); + +ALTER TABLE v2_oauth2_authorization ADD INDEX IF NOT EXISTS I_authorization_access_token (access_token); +ALTER TABLE v2_oauth2_authorization ADD INDEX IF NOT EXISTS I_authorization_code_token (code_token); + +ALTER TABLE v2_client ADD INDEX IF NOT EXISTS I_client_client_id (client_id); -- 2.39.5