From 95e2c1de99e0e19971de92e25803ce375b8092da Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Mon, 13 Jan 2025 13:32:38 +0000 Subject: [PATCH] Add missing index to AlertRuns There is a query counting on the AlertRuns for today and, given the size of the table, it takes long time due to the lack of an index for the date field. --- db/schema.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 9d109aaa15..f986265c8f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_01_07_110428) do +ActiveRecord::Schema[7.2].define(version: 2025_01_13_131902) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" enable_extension "citext" @@ -56,6 +56,7 @@ t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.integer "status", default: 0 + t.index ["run_on"], name: "index_alert_runs_on_run_on" t.index ["subscription_id"], name: "index_alert_runs_on_subscription_id" end