From acc7f1217ae3c37d2960ff56f0b3f1080ab7d359 Mon Sep 17 00:00:00 2001 From: Rory McKinley Date: Mon, 27 Jan 2025 07:08:46 +0200 Subject: [PATCH] Add indexes on `workflow_edges` and `steps` tables (#2849) * Add indexes to foreign keys - Attempting to resolve slow editor loading issues * Update CHANGELOG * Make index additions idempotent * Remove conflict artifact from CHANGELOG.md --- CHANGELOG.md | 3 +++ .../20250122110318_index_workflow_id_on_workflow_edges.exs | 7 +++++++ .../migrations/20250122110504_index_job_id_on_steps.exs | 7 +++++++ 3 files changed, 17 insertions(+) create mode 100644 priv/repo/migrations/20250122110318_index_workflow_id_on_workflow_edges.exs create mode 100644 priv/repo/migrations/20250122110504_index_job_id_on_steps.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 713e88c61a..8791642740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ and this project adheres to [#2718](https://github.com/OpenFn/lightning/issues/2718) - Temporary instrumentation for JobEditor to help identify performance issues. [#2617](https://github.com/OpenFn/lightning/issues/2617) +- Indexes to foreign keys on `workflow_edges` and `steps` tables to try and + alleviate slow loading of the job editor. + [#2617](https://github.com/OpenFn/lightning/issues/2617) ### Changed diff --git a/priv/repo/migrations/20250122110318_index_workflow_id_on_workflow_edges.exs b/priv/repo/migrations/20250122110318_index_workflow_id_on_workflow_edges.exs new file mode 100644 index 0000000000..31c52a2ef7 --- /dev/null +++ b/priv/repo/migrations/20250122110318_index_workflow_id_on_workflow_edges.exs @@ -0,0 +1,7 @@ +defmodule Lightning.Repo.Migrations.IndexWorkflowIdOnWorkflowEdges do + use Ecto.Migration + + def change do + create_if_not_exists index(:workflow_edges, [:workflow_id]) + end +end diff --git a/priv/repo/migrations/20250122110504_index_job_id_on_steps.exs b/priv/repo/migrations/20250122110504_index_job_id_on_steps.exs new file mode 100644 index 0000000000..2110853b95 --- /dev/null +++ b/priv/repo/migrations/20250122110504_index_job_id_on_steps.exs @@ -0,0 +1,7 @@ +defmodule Lightning.Repo.Migrations.IndexJobIdOnSteps do + use Ecto.Migration + + def change do + create_if_not_exists index(:steps, [:job_id]) + end +end