Skip to content

Commit

Permalink
feat: improve secondary indices for self service tables
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 29, 2024
1 parent 1a78af0 commit ea125e2
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE INDEX IF NOT EXISTS selfservice_login_flows_nid_id_idx ON selfservice_login_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_login_flows_id_nid_idx ON selfservice_login_flows (id ASC, nid ASC);
DROP INDEX IF EXISTS selfservice_login_flows_nid_idx;

CREATE INDEX IF NOT EXISTS selfservice_errors_errors_nid_id_idx (nid ASC, id ASC);
DROP INDEX IF EXISTS selfservice_errors_errors_nid_idx (nid ASC);

CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_nid_id_idx ON selfservice_recovery_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_id_nid_idx ON selfservice_recovery_flows (id ASC, nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_recovered_identity_id_nid_idx ON selfservice_recovery_flows (recovered_identity_id ASC, nid ASC);

DROP INDEX IF EXISTS selfservice_recovery_flows_nid_idx;
DROP INDEX IF EXISTS selfservice_recovery_flows_recovered_identity_id_idx;

CREATE INDEX IF NOT EXISTS selfservice_registration_flows_nid_id_idx ON selfservice_registration_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_registration_flows_id_nid_idx ON selfservice_registration_flows (id ASC, nid ASC);

DROP INDEX IF EXISTS selfservice_registration_flows_nid_idx;

CREATE INDEX IF NOT EXISTS selfservice_settings_flows_nid_id_idx ON selfservice_settings_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_settings_flows_id_nid_idx ON selfservice_settings_flows (id ASC, nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_settings_flows_identity_id_nid_idx ON selfservice_settings_flows (identity_id ASC, nid ASC);

DROP INDEX IF EXISTS selfservice_settings_flows_nid_idx;
DROP INDEX IF EXISTS selfservice_settings_flows_identity_id_idx;

CREATE INDEX IF NOT EXISTS selfservice_verification_flows_nid_id_idx ON selfservice_verification_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_verification_flows_id_nid_idx ON selfservice_verification_flows (id ASC, nid ASC);
DROP INDEX IF EXISTS selfservice_verification_flows_nid_idx ON selfservice_verification_flows;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE INDEX IF NOT EXISTS selfservice_login_flows_nid_id_idx ON selfservice_login_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_login_flows_id_nid_idx ON selfservice_login_flows (id ASC, nid ASC);
DROP INDEX selfservice_login_flows_nid_idx ON selfservice_login_flows;

CREATE INDEX IF NOT EXISTS selfservice_errors_errors_nid_id_idx (nid ASC, id ASC);
DROP INDEX IF EXISTS selfservice_errors_errors_nid_idx (nid ASC);

CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_nid_id_idx ON selfservice_recovery_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_id_nid_idx ON selfservice_recovery_flows (id ASC, nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_recovered_identity_id_nid_idx ON selfservice_recovery_flows (recovered_identity_id ASC, nid ASC);
DROP INDEX selfservice_recovery_flows_nid_idx ON selfservice_recovery_flows;
DROP INDEX selfservice_recovery_flows_recovered_identity_id_idx ON selfservice_recovery_flows;

CREATE INDEX IF NOT EXISTS selfservice_registration_flows_nid_id_idx ON selfservice_registration_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_registration_flows_id_nid_idx ON selfservice_registration_flows (id ASC, nid ASC);
DROP INDEX selfservice_registration_flows_nid_idx ON selfservice_registration_flows;

CREATE INDEX IF NOT EXISTS selfservice_settings_flows_nid_id_idx ON selfservice_settings_flows (nid ASC, id ASC);
CREATE INDEX IF NOT EXISTS selfservice_settings_flows_id_nid_idx ON selfservice_settings_flows (id ASC, nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_settings_flows_identity_id_nid_idx ON selfservice_settings_flows (identity_id ASC, nid ASC);
DROP INDEX selfservice_settings_flows_nid_idx ON selfservice_settings_flows;
DROP INDEX selfservice_settings_flows_identity_id_idx ON selfservice_settings_flows;

CREATE INDEX selfservice_verification_flows_nid_id_idx ON selfservice_verification_flows (nid ASC, id ASC);
CREATE INDEX selfservice_verification_flows_id_nid_idx ON selfservice_verification_flows (id ASC, nid ASC);
DROP INDEX selfservice_verification_flows_nid_idx ON selfservice_verification_flows;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE INDEX IF NOT EXISTS selfservice_login_flows_nid_idx ON selfservice_login_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_login_flows_nid_id_idx ON selfservice_login_flows;
DROP INDEX IF EXISTS selfservice_login_flows_id_nid_idx ON selfservice_login_flows;

CREATE INDEX IF NOT EXISTS selfservice_errors_errors_nid_idx (nid ASC);
DROP INDEX IF EXISTS selfservice_errors_errors_nid_id_idx (nid ASC, id ASC);

CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_nid_idx ON selfservice_recovery_flows (nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_recovered_identity_id_idx ON selfservice_recovery_flows (recovered_identity_id ASC);
DROP INDEX IF EXISTS selfservice_recovery_flows_nid_id_idx ON selfservice_recovery_flows;
DROP INDEX IF EXISTS selfservice_recovery_flows_id_nid_idx ON selfservice_recovery_flows;
DROP INDEX IF EXISTS selfservice_recovery_flows_recovered_identity_id_nid_idx ON selfservice_recovery_flows;

CREATE INDEX IF NOT EXISTS selfservice_registration_flows_nid_idx ON selfservice_registration_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_registration_flows_nid_id_idx ON selfservice_registration_flows;
DROP INDEX IF EXISTS selfservice_registration_flows_id_nid_idx ON selfservice_registration_flows;

CREATE INDEX IF NOT EXISTS selfservice_settings_flows_nid_idx ON selfservice_settings_flows (nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_settings_flows_identity_id_idx ON selfservice_settings_flows (identity_id ASC);
DROP INDEX IF EXISTS selfservice_settings_flows_nid_id_idx ON selfservice_settings_flows;
DROP INDEX IF EXISTS selfservice_settings_flows_id_nid_idx ON selfservice_settings_flows;
DROP INDEX IF EXISTS selfservice_settings_flows_identity_id_nid_idx ON selfservice_settings_flows;

CREATE INDEX IF NOT EXISTS selfservice_verification_flows_nid_idx ON selfservice_verification_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_verification_flows_nid_id_idx ON selfservice_verification_flows;
DROP INDEX IF EXISTS selfservice_verification_flows_id_nid_idx ON selfservice_verification_flows;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE INDEX IF NOT EXISTS selfservice_login_flows_nid_idx ON selfservice_login_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_login_flows_nid_id_idx;
DROP INDEX IF EXISTS selfservice_login_flows_id_nid_idx;

CREATE INDEX IF NOT EXISTS selfservice_errors_errors_nid_idx (nid ASC);
DROP INDEX IF EXISTS selfservice_errors_errors_nid_id_idx (nid ASC, id ASC);

CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_recovered_identity_id_idx ON selfservice_recovery_flows (recovered_identity_id ASC);
CREATE INDEX IF NOT EXISTS selfservice_recovery_flows_nid_idx ON selfservice_recovery_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_recovery_flows_nid_id_idx;
DROP INDEX IF EXISTS selfservice_recovery_flows_id_nid_idx;
DROP INDEX IF EXISTS selfservice_recovery_flows_recovered_identity_id_nid_idx;

CREATE INDEX IF NOT EXISTS selfservice_registration_flows_nid_idx ON selfservice_registration_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_registration_flows_nid_id_idx;
DROP INDEX IF EXISTS selfservice_registration_flows_id_nid_idx;

CREATE INDEX IF NOT EXISTS selfservice_settings_flows_nid_idx ON selfservice_settings_flows (nid ASC);
CREATE INDEX IF NOT EXISTS selfservice_settings_flows_identity_id_idx ON selfservice_settings_flows (identity_id ASC);
DROP INDEX IF EXISTS selfservice_settings_flows_nid_id_idx;
DROP INDEX IF EXISTS selfservice_settings_flows_id_nid_idx;
DROP INDEX IF EXISTS selfservice_settings_flows_identity_id_nid_idx;

CREATE INDEX IF NOT EXISTS selfservice_verification_flows_nid_idx ON selfservice_verification_flows (nid ASC);
DROP INDEX IF EXISTS selfservice_verification_flows_nid_id_idx;
DROP INDEX IF EXISTS selfservice_verification_flows_id_nid_idx;

0 comments on commit ea125e2

Please sign in to comment.