-
Notifications
You must be signed in to change notification settings - Fork 969
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove total count from listSessions and improve secondary …
…indices (#4173) This patch changes sorting to improve performance on list session endpoints. It also removes the `x-total-count` header from list responses. BREAKING CHANGE: The total count header `x-total-count` will no longer be sent in response to `GET /admin/sessions` requests. Closes ory-corp/cloud#7177 Closes ory-corp/cloud#7175 Closes ory-corp/cloud#7176
- Loading branch information
Showing
20 changed files
with
123 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...sql/migrations/sql/20241023142500000001_drop_unused_indices_identity_credentials.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE INDEX IF NOT EXISTS identity_credentials_id_nid_idx ON identity_credentials (id ASC, nid ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credentials_nid_id_idx ON identity_credentials (nid ASC, id ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credentials_nid_identity_id_idx ON identity_credentials (identity_id ASC, nid ASC); | ||
|
||
DROP INDEX IF EXISTS identity_credentials_identity_id_idx; | ||
DROP INDEX IF EXISTS identity_credentials_nid_idx; |
4 changes: 4 additions & 0 deletions
4
...grations/sql/20241023142500000001_drop_unused_indices_identity_credentials.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE INDEX identity_credentials_id_nid_idx ON identity_credentials (id ASC, nid ASC); | ||
CREATE INDEX identity_credentials_nid_id_idx ON identity_credentials (nid ASC, id ASC); | ||
|
||
DROP INDEX identity_credentials_nid_idx ON identity_credentials; |
5 changes: 5 additions & 0 deletions
5
...migrations/sql/20241023142500000001_drop_unused_indices_identity_credentials.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE INDEX identity_credentials_nid_idx ON identity_credentials (nid ASC); | ||
|
||
DROP INDEX identity_credentials_id_nid_idx ON identity_credentials; | ||
DROP INDEX identity_credentials_nid_id_idx ON identity_credentials; | ||
|
6 changes: 6 additions & 0 deletions
6
...e/sql/migrations/sql/20241023142500000001_drop_unused_indices_identity_credentials.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE INDEX IF NOT EXISTS identity_credentials_identity_id_idx ON identity_credentials (identity_id ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credentials_nid_idx ON identity_credentials (nid ASC); | ||
|
||
DROP INDEX IF EXISTS identity_credentials_id_nid_idx; | ||
DROP INDEX IF EXISTS identity_credentials_nid_id_idx; | ||
DROP INDEX IF EXISTS identity_credentials_nid_identity_id_idx; |
9 changes: 9 additions & 0 deletions
9
persistence/sql/migrations/sql/20241023142500000002_drop_unused_indices_sessions.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE INDEX IF NOT EXISTS sessions_nid_id_identity_id_idx ON sessions(nid ASC, identity_id ASC, id ASC); | ||
CREATE INDEX IF NOT EXISTS sessions_id_nid_idx ON sessions(id ASC, nid ASC); | ||
CREATE INDEX IF NOT EXISTS sessions_token_nid_idx ON sessions(nid ASC, token ASC); | ||
CREATE INDEX IF NOT EXISTS sessions_identity_id_nid_sorted_idx ON sessions(identity_id ASC, nid ASC, authenticated_at DESC); | ||
CREATE INDEX IF NOT EXISTS sessions_nid_created_at_id_idx ON sessions(nid ASC, created_at DESC, id ASC); | ||
|
||
DROP INDEX IF EXISTS sessions_list_idx; | ||
DROP INDEX IF EXISTS sessions_list_active_idx; | ||
DROP INDEX IF EXISTS sessions_list_identity_idx; |
9 changes: 9 additions & 0 deletions
9
...tence/sql/migrations/sql/20241023142500000002_drop_unused_indices_sessions.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE INDEX sessions_nid_id_identity_id_idx ON sessions(nid ASC, identity_id ASC, id ASC); | ||
CREATE INDEX sessions_id_nid_idx ON sessions(id ASC, nid ASC); | ||
CREATE INDEX sessions_token_nid_idx ON sessions(nid ASC, token ASC); | ||
CREATE INDEX sessions_identity_id_nid_sorted_idx ON sessions(identity_id ASC, nid ASC, authenticated_at DESC); | ||
CREATE INDEX sessions_nid_created_at_id_idx ON sessions(nid ASC, created_at DESC, id ASC); | ||
|
||
DROP INDEX sessions_list_idx ON sessions; | ||
DROP INDEX sessions_list_active_idx ON sessions; | ||
DROP INDEX sessions_list_identity_idx ON sessions; |
9 changes: 9 additions & 0 deletions
9
...istence/sql/migrations/sql/20241023142500000002_drop_unused_indices_sessions.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE INDEX sessions_list_idx ON sessions (nid ASC, created_at DESC, id ASC); | ||
CREATE INDEX sessions_list_active_idx ON sessions (nid ASC, expires_at ASC, active ASC, created_at DESC, id ASC); | ||
CREATE INDEX sessions_list_identity_idx ON sessions (identity_id ASC, nid ASC, created_at DESC); | ||
|
||
DROP INDEX sessions_nid_id_identity_id_idx ON sessions; | ||
DROP INDEX sessions_id_nid_idx ON sessions; | ||
DROP INDEX sessions_token_nid_idx ON sessions; | ||
DROP INDEX sessions_identity_id_nid_sorted_idx ON sessions; | ||
DROP INDEX sessions_nid_created_at_id_idx ON sessions; |
9 changes: 9 additions & 0 deletions
9
persistence/sql/migrations/sql/20241023142500000002_drop_unused_indices_sessions.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE INDEX IF NOT EXISTS sessions_list_idx ON sessions (nid ASC, created_at DESC, id ASC); | ||
CREATE INDEX IF NOT EXISTS sessions_list_active_idx ON sessions (nid ASC, expires_at ASC, active ASC, created_at DESC, id ASC); | ||
CREATE INDEX IF NOT EXISTS sessions_list_identity_idx ON sessions (identity_id ASC, nid ASC, created_at DESC); | ||
|
||
DROP INDEX IF EXISTS sessions_nid_id_identity_id_idx; | ||
DROP INDEX IF EXISTS sessions_id_nid_idx; | ||
DROP INDEX IF EXISTS sessions_token_nid_idx; | ||
DROP INDEX IF EXISTS sessions_identity_id_nid_sorted_idx; | ||
DROP INDEX IF EXISTS sessions_nid_created_at_id_idx; |
11 changes: 11 additions & 0 deletions
11
...ns/sql/20241023142500000003_drop_unused_indices_credential_identifiers.cockroach.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- THIS IS COCKROACH ONLY | ||
ALTER INDEX identity_credential_identifiers_identifier_nid_type_uq_idx RENAME TO identity_credential_identifiers_identifier_nid_type_uq_idx_deleteme; | ||
CREATE UNIQUE INDEX IF NOT EXISTS identity_credential_identifiers_identifier_nid_type_uq_idx ON identity_credential_identifiers(nid ASC, identity_credential_type_id ASC, identifier ASC); | ||
DROP INDEX IF EXISTS identity_credential_identifiers_identifier_nid_type_uq_idx_deleteme; | ||
-- | ||
|
||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_nid_id_idx ON identity_credential_identifiers (nid ASC, id ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_id_nid_idx ON identity_credential_identifiers (id ASC, nid ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_nid_identity_credential_id_idx ON identity_credential_identifiers (identity_credential_id ASC, nid ASC); | ||
|
||
DROP INDEX IF EXISTS identity_credential_identifiers_identity_credential_id_idx; |
11 changes: 11 additions & 0 deletions
11
...ions/sql/20241023142500000003_drop_unused_indices_credential_identifiers.cockroach.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- THIS IS COCKROACH ONLY | ||
ALTER INDEX identity_credential_identifiers_identifier_nid_type_uq_idx RENAME TO identity_credential_identifiers_identifier_nid_type_uq_idx_deleteme; | ||
CREATE UNIQUE INDEX IF NOT EXISTS identity_credential_identifiers_identifier_nid_type_uq_idx ON identity_credential_identifiers (nid ASC, identity_credential_type_id ASC, identifier ASC) STORING (identity_credential_id); | ||
DROP INDEX IF EXISTS identity_credential_identifiers_identifier_nid_type_uq_idx_deleteme; | ||
-- | ||
|
||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_identity_credential_id_idx ON identity_credential_identifiers (identity_credential_id ASC); | ||
|
||
DROP INDEX IF EXISTS identity_credential_identifiers_nid_id_idx; | ||
DROP INDEX IF EXISTS identity_credential_identifiers_id_nid_idx; | ||
DROP INDEX IF EXISTS identity_credential_identifiers_nid_identity_credential_id_idx; |
5 changes: 5 additions & 0 deletions
5
...l/migrations/sql/20241023142500000003_drop_unused_indices_credential_identifiers.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_nid_id_idx ON identity_credential_identifiers (nid ASC, id ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_id_nid_idx ON identity_credential_identifiers (id ASC, nid ASC); | ||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_nid_identity_credential_id_idx ON identity_credential_identifiers (identity_credential_id ASC, nid ASC); | ||
|
||
DROP INDEX IF EXISTS identity_credential_identifiers_identity_credential_id_idx; |
5 changes: 5 additions & 0 deletions
5
...ations/sql/20241023142500000003_drop_unused_indices_credential_identifiers.mysql.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE INDEX identity_credential_identifiers_nid_id_idx ON identity_credential_identifiers (nid ASC, id ASC); | ||
CREATE INDEX identity_credential_identifiers_id_nid_idx ON identity_credential_identifiers (id ASC, nid ASC); | ||
CREATE INDEX identity_credential_identifiers_nid_identity_credential_id_idx ON identity_credential_identifiers (identity_credential_id ASC, nid ASC); | ||
|
||
DROP INDEX identity_credential_identifiers_identity_credential_id_idx ON identity_credential_identifiers; |
5 changes: 5 additions & 0 deletions
5
...grations/sql/20241023142500000003_drop_unused_indices_credential_identifiers.mysql.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE INDEX identity_credential_identifiers_identity_credential_id_idx ON identity_credential_identifiers (identity_credential_id ASC); | ||
|
||
DROP INDEX identity_credential_identifiers_nid_id_idx ON identity_credential_identifiers; | ||
DROP INDEX identity_credential_identifiers_id_nid_idx ON identity_credential_identifiers; | ||
DROP INDEX identity_credential_identifiers_nid_identity_credential_id_idx ON identity_credential_identifiers; |
5 changes: 5 additions & 0 deletions
5
...sql/migrations/sql/20241023142500000003_drop_unused_indices_credential_identifiers.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_identity_credential_id_idx ON identity_credential_identifiers (identity_credential_id ASC); | ||
|
||
DROP INDEX IF EXISTS identity_credential_identifiers_nid_id_idx; | ||
DROP INDEX IF EXISTS identity_credential_identifiers_id_nid_idx; | ||
DROP INDEX IF EXISTS identity_credential_identifiers_nid_identity_credential_id_idx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters