Skip to content

Commit

Permalink
fix: better index for config.user_handle on identity_credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Apr 26, 2024
1 parent 00246ee commit 81dd37c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions persistence/sql/identity/persister_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ INNER JOIN identity_credentials
FROM identity_credential_types
WHERE name = ?
)
WHERE identity_credentials.config ->> '%s' = ?
WHERE identity_credentials.config ->> '%s' = ? AND identity_credentials.config ->> '%s' IS NOT NULL
AND identities.nid = ?
LIMIT 1`, jsonPath),
LIMIT 1`, jsonPath, jsonPath),
identity.CredentialsTypeWebAuthn,
base64.StdEncoding.EncodeToString(userHandle),
p.NetworkID(ctx),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DROP INDEX identity_credentials_config_user_handle_idx;

CREATE INVERTED INDEX identity_credentials_user_handle_idx
ON identity_credentials (config)
WHERE config ->> 'user_handle' IS NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DROP INDEX identity_credentials_user_handle_idx;

CREATE INDEX identity_credentials_config_user_handle_idx
ON identity_credentials ((config ->> 'user_handle'))
WHERE config ->> 'user_handle' IS NOT NULL
;

0 comments on commit 81dd37c

Please sign in to comment.