From 66d20cabacaee1cfcf43a374b471d09276f1d73e Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Wed, 16 Nov 2022 14:40:57 -0600 Subject: [PATCH] fix: index `GetWorkspaceAgentsByResourceIDs` query (#5021) --- coderd/database/dump.sql | 2 ++ .../migrations/000078_workspace_agents_resource_id_idx.down.sql | 1 + .../migrations/000078_workspace_agents_resource_id_idx.up.sql | 1 + 3 files changed, 4 insertions(+) create mode 100644 coderd/database/migrations/000078_workspace_agents_resource_id_idx.down.sql create mode 100644 coderd/database/migrations/000078_workspace_agents_resource_id_idx.up.sql diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index 6cf8c0d4bf..a7c6394b34 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -632,6 +632,8 @@ CREATE UNIQUE INDEX users_email_lower_idx ON users USING btree (lower(email)) WH CREATE UNIQUE INDEX users_username_lower_idx ON users USING btree (lower(username)) WHERE (deleted = false); +CREATE INDEX workspace_agents_resource_id_idx ON workspace_agents USING btree (resource_id); + CREATE INDEX workspace_resources_job_id_idx ON workspace_resources USING btree (job_id); CREATE UNIQUE INDEX workspaces_owner_id_lower_idx ON workspaces USING btree (owner_id, lower((name)::text)) WHERE (deleted = false); diff --git a/coderd/database/migrations/000078_workspace_agents_resource_id_idx.down.sql b/coderd/database/migrations/000078_workspace_agents_resource_id_idx.down.sql new file mode 100644 index 0000000000..b94373858a --- /dev/null +++ b/coderd/database/migrations/000078_workspace_agents_resource_id_idx.down.sql @@ -0,0 +1 @@ +DROP INDEX workspace_agents_resource_id_idx; diff --git a/coderd/database/migrations/000078_workspace_agents_resource_id_idx.up.sql b/coderd/database/migrations/000078_workspace_agents_resource_id_idx.up.sql new file mode 100644 index 0000000000..b5dbc2abfd --- /dev/null +++ b/coderd/database/migrations/000078_workspace_agents_resource_id_idx.up.sql @@ -0,0 +1 @@ +CREATE INDEX workspace_agents_resource_id_idx ON workspace_agents USING btree (resource_id);