From f3eb66220880f2e112f88a1db61bb66949e9def0 Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Thu, 10 Nov 2022 14:09:44 -0600 Subject: [PATCH] fix: add index for `workspace_resource.job_id` column (#5009) --- coderd/database/dump.sql | 2 ++ .../migrations/000074_workspace_resources_job_id_idx.down.sql | 1 + .../migrations/000074_workspace_resources_job_id_idx.up.sql | 1 + 3 files changed, 4 insertions(+) create mode 100644 coderd/database/migrations/000074_workspace_resources_job_id_idx.down.sql create mode 100644 coderd/database/migrations/000074_workspace_resources_job_id_idx.up.sql diff --git a/coderd/database/dump.sql b/coderd/database/dump.sql index 2b369cf167..dfaf8e0451 100644 --- a/coderd/database/dump.sql +++ b/coderd/database/dump.sql @@ -624,6 +624,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_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); ALTER TABLE ONLY api_keys diff --git a/coderd/database/migrations/000074_workspace_resources_job_id_idx.down.sql b/coderd/database/migrations/000074_workspace_resources_job_id_idx.down.sql new file mode 100644 index 0000000000..1382a80feb --- /dev/null +++ b/coderd/database/migrations/000074_workspace_resources_job_id_idx.down.sql @@ -0,0 +1 @@ +DROP INDEX workspace_resources_job_id_idx; diff --git a/coderd/database/migrations/000074_workspace_resources_job_id_idx.up.sql b/coderd/database/migrations/000074_workspace_resources_job_id_idx.up.sql new file mode 100644 index 0000000000..29bd6798b4 --- /dev/null +++ b/coderd/database/migrations/000074_workspace_resources_job_id_idx.up.sql @@ -0,0 +1 @@ +CREATE INDEX CONCURRENTLY workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);