mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 15:49:35 +00:00
fix: add user id index on sessions8 (#9834)
# Which Problems Are Solved
When a user changes their password, Zitadel needs to terminate all of
that user's active sessions. This query can take many seconds on
deployments with large session and user tables. This happens as part of
session projection handling, so doesn't directly impact user experience,
but potentially bogs down the projection handler which isn't great. In
the future, this index could be used to power a "see all of my current
sessions" feature in Zitadel.
# How the Problems Are Solved
Adds new index on `user_id` column on `projections.sessions8` table.
Alternatively, we can index on `(instance_id, user_id)` instead but
opted for keeping the index smaller as we already index on `instance_id`
separately.
# Additional Changes
None
# Additional Context
None
---------
Co-authored-by: Silvan <27845747+adlerhurst@users.noreply.github.com>
(cherry picked from commit 8cb1d24b36
)
This commit is contained in:

committed by
Livio Spring

parent
d4ec519af6
commit
fccfa0d35d
@@ -87,6 +87,7 @@ func (*sessionProjection) Init() *old_handler.Check {
|
||||
SessionColumnUserAgentFingerprintID+"_idx",
|
||||
[]string{SessionColumnUserAgentFingerprintID},
|
||||
)),
|
||||
handler.WithIndex(handler.NewIndex(SessionColumnUserID+"_idx", []string{SessionColumnUserID})),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user