-
-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize identity-related secondary indices (#4182)
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
persistence/sql/migrations/sql/20241029153900000001_identities.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,13 @@ | ||
CREATE INDEX IF NOT EXISTS identities_id_nid_idx ON identities (id ASC, nid ASC); | ||
|
||
CREATE INDEX IF NOT EXISTS identity_recovery_addresses_status_via_idx ON identity_recovery_addresses (nid ASC, via ASC, value ASC); | ||
CREATE INDEX IF NOT EXISTS identity_recovery_addresses_nid_identity_id_idx ON identity_recovery_addresses (identity_id ASC, nid ASC); | ||
CREATE INDEX IF NOT EXISTS identity_recovery_addresses_nid_id_idx ON identity_recovery_addresses (nid ASC, id ASC); | ||
CREATE INDEX IF NOT EXISTS identity_recovery_addresses_id_nid_idx ON identity_recovery_addresses (id ASC, nid ASC); | ||
DROP INDEX IF EXISTS identity_recovery_addresses_identity_id_idx; | ||
|
||
CREATE INDEX IF NOT EXISTS identity_verifiable_addresses_status_via_idx ON identity_verifiable_addresses (nid ASC, via ASC, value ASC); | ||
CREATE INDEX IF NOT EXISTS identity_verifiable_addresses_nid_identity_id_idx ON identity_verifiable_addresses (identity_id ASC, nid ASC); | ||
CREATE INDEX IF NOT EXISTS identity_verifiable_addresses_nid_id_idx ON identity_verifiable_addresses (nid ASC, id ASC); | ||
CREATE INDEX IF NOT EXISTS identity_verifiable_addresses_id_nid_idx ON identity_verifiable_addresses (id ASC, nid ASC); | ||
DROP INDEX IF EXISTS identity_verifiable_addresses_identity_id_idx; |
17 changes: 17 additions & 0 deletions
17
persistence/sql/migrations/sql/20241029153900000001_identities.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,17 @@ | ||
CREATE INDEX identities_id_nid_idx ON identities (id ASC, nid ASC); | ||
|
||
CREATE INDEX identity_recovery_addresses_status_via_idx ON identity_recovery_addresses (nid ASC, via ASC, value ASC); | ||
-- While this index did not exist in the past, it is needed in MySQL for foreign key relations. We accept | ||
-- that this index is "unaccounted" for if we execute down and then up migrations on MySQL. | ||
CREATE INDEX identity_recovery_addresses_identity_id_fk_idx ON identity_recovery_addresses (identity_id ASC); | ||
CREATE INDEX identity_recovery_addresses_nid_id_idx ON identity_recovery_addresses (nid ASC, id ASC); | ||
CREATE INDEX identity_recovery_addresses_id_nid_idx ON identity_recovery_addresses (id ASC, nid ASC); | ||
DROP INDEX identity_recovery_addresses_identity_id_idx ON identity_recovery_addresses; | ||
|
||
CREATE INDEX identity_verifiable_addresses_status_via_idx ON identity_verifiable_addresses (nid ASC, via ASC, value ASC); | ||
-- While this index did not exist in the past, it is needed in MySQL for foreign key relations. We accept | ||
-- that this index is "unaccounted" for if we execute down and then up migrations on MySQL. | ||
CREATE INDEX identity_verifiable_addresses_identity_id_fk_idx ON identity_verifiable_addresses (identity_id ASC); | ||
CREATE INDEX identity_verifiable_addresses_nid_id_idx ON identity_verifiable_addresses (nid ASC, id ASC); | ||
CREATE INDEX identity_verifiable_addresses_id_nid_idx ON identity_verifiable_addresses (id ASC, nid ASC); | ||
DROP INDEX identity_verifiable_addresses_identity_id_idx ON identity_verifiable_addresses; |
13 changes: 13 additions & 0 deletions
13
persistence/sql/migrations/sql/20241029153900000001_identities.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,13 @@ | ||
DROP INDEX identities_id_nid_idx ON identities; | ||
|
||
CREATE INDEX identity_recovery_addresses_identity_id_idx ON identity_recovery_addresses (identity_id ASC); | ||
DROP INDEX identity_recovery_addresses_status_via_idx ON identity_recovery_addresses; | ||
-- DROP INDEX identity_recovery_addresses_nid_identity_id_idx ON identity_recovery_addresses; | ||
DROP INDEX identity_recovery_addresses_nid_id_idx ON identity_recovery_addresses; | ||
DROP INDEX identity_recovery_addresses_id_nid_idx ON identity_recovery_addresses; | ||
|
||
CREATE INDEX identity_verifiable_addresses_identity_id_idx ON identity_verifiable_addresses (identity_id ASC); | ||
DROP INDEX identity_verifiable_addresses_status_via_idx ON identity_verifiable_addresses; | ||
-- DROP INDEX identity_verifiable_addresses_nid_identity_id_idx ON identity_verifiable_addresses; | ||
DROP INDEX identity_verifiable_addresses_nid_id_idx ON identity_verifiable_addresses; | ||
DROP INDEX identity_verifiable_addresses_id_nid_idx ON identity_verifiable_addresses; |
13 changes: 13 additions & 0 deletions
13
persistence/sql/migrations/sql/20241029153900000001_identities.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,13 @@ | ||
DROP INDEX IF EXISTS identities_id_nid_idx; | ||
|
||
CREATE INDEX IF NOT EXISTS identity_recovery_addresses_identity_id_idx ON identity_recovery_addresses(identity_id ASC); | ||
DROP INDEX IF EXISTS identity_recovery_addresses_status_via_idx; | ||
DROP INDEX IF EXISTS identity_recovery_addresses_nid_identity_id_idx; | ||
DROP INDEX IF EXISTS identity_recovery_addresses_nid_id_idx; | ||
DROP INDEX IF EXISTS identity_recovery_addresses_id_nid_idx; | ||
|
||
CREATE INDEX IF NOT EXISTS identity_verifiable_addresses_identity_id_idx ON identity_verifiable_addresses (identity_id ASC); | ||
DROP INDEX IF EXISTS identity_verifiable_addresses_status_via_idx; | ||
DROP INDEX IF EXISTS identity_verifiable_addresses_nid_identity_id_idx; | ||
DROP INDEX IF EXISTS identity_verifiable_addresses_nid_id_idx; | ||
DROP INDEX IF EXISTS identity_verifiable_addresses_id_nid_idx; |