From 3a37e337c099948a76b1cd301bebfb25b29bb9cc Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 14 Jan 2022 15:44:06 +0100 Subject: [PATCH] fix: add `identity_id` index to `identity_verifiable_addresses` table (#2147) The verifiable addresses are loaded eagerly into the identity. When that happens, the `identity_verifiable_addresses` table is queried by `nid` and `identity_id`. This index should greatly improve performance, especially of the `/sessions/whoami` endpoint. --- ...5828000000_verified_address_identity_index.cockroach.down.sql | 1 + ...135828000000_verified_address_identity_index.cockroach.up.sql | 1 + ...14135828000000_verified_address_identity_index.mysql.down.sql | 1 + ...0114135828000000_verified_address_identity_index.mysql.up.sql | 1 + ...35828000000_verified_address_identity_index.postgres.down.sql | 1 + ...4135828000000_verified_address_identity_index.postgres.up.sql | 1 + ...135828000000_verified_address_identity_index.sqlite3.down.sql | 1 + ...14135828000000_verified_address_identity_index.sqlite3.up.sql | 1 + .../20220114135828_verified_address_identity_index.down.fizz | 1 + .../20220114135828_verified_address_identity_index.up.fizz | 1 + 10 files changed, 10 insertions(+) create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.down.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.up.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.down.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.up.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.down.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.up.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.down.sql create mode 100644 persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.up.sql create mode 100644 persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.down.fizz create mode 100644 persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.up.fizz diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.down.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.down.sql new file mode 100644 index 000000000000..5ecab22bf36e --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.down.sql @@ -0,0 +1 @@ +DROP INDEX IF EXISTS "identity_verifiable_addresses_nid_identity_id_idx"; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.up.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.up.sql new file mode 100644 index 000000000000..ced74f360389 --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.cockroach.up.sql @@ -0,0 +1 @@ +CREATE INDEX "identity_verifiable_addresses_nid_identity_id_idx" ON "identity_verifiable_addresses" (nid, identity_id); \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.down.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.down.sql new file mode 100644 index 000000000000..0dc2148caed5 --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.down.sql @@ -0,0 +1 @@ +DROP INDEX `identity_verifiable_addresses_nid_identity_id_idx` ON `identity_verifiable_addresses`; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.up.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.up.sql new file mode 100644 index 000000000000..0fee3ecbcb66 --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.mysql.up.sql @@ -0,0 +1 @@ +CREATE INDEX `identity_verifiable_addresses_nid_identity_id_idx` ON `identity_verifiable_addresses` (`nid`, `identity_id`); \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.down.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.down.sql new file mode 100644 index 000000000000..4bb7cb319ef6 --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.down.sql @@ -0,0 +1 @@ +DROP INDEX "identity_verifiable_addresses_nid_identity_id_idx"; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.up.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.up.sql new file mode 100644 index 000000000000..ced74f360389 --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.postgres.up.sql @@ -0,0 +1 @@ +CREATE INDEX "identity_verifiable_addresses_nid_identity_id_idx" ON "identity_verifiable_addresses" (nid, identity_id); \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.down.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.down.sql new file mode 100644 index 000000000000..5ecab22bf36e --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.down.sql @@ -0,0 +1 @@ +DROP INDEX IF EXISTS "identity_verifiable_addresses_nid_identity_id_idx"; \ No newline at end of file diff --git a/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.up.sql b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.up.sql new file mode 100644 index 000000000000..ced74f360389 --- /dev/null +++ b/persistence/sql/migrations/sql/20220114135828000000_verified_address_identity_index.sqlite3.up.sql @@ -0,0 +1 @@ +CREATE INDEX "identity_verifiable_addresses_nid_identity_id_idx" ON "identity_verifiable_addresses" (nid, identity_id); \ No newline at end of file diff --git a/persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.down.fizz b/persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.down.fizz new file mode 100644 index 000000000000..a2947f7a83b3 --- /dev/null +++ b/persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.down.fizz @@ -0,0 +1 @@ +drop_index("identity_verifiable_addresses", "identity_verifiable_addresses_nid_identity_id_idx") diff --git a/persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.up.fizz b/persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.up.fizz new file mode 100644 index 000000000000..d82e66992d70 --- /dev/null +++ b/persistence/sql/migrations/templates/20220114135828_verified_address_identity_index.up.fizz @@ -0,0 +1 @@ +add_index("identity_verifiable_addresses", ["nid", "identity_id"], { "name": "identity_verifiable_addresses_nid_identity_id_idx" })