Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions db/migrate/20260901220117_index_current_cycle_join_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# recommendation_categories and measure_indicators back CurrentCycle's hot
# queries (see app/models/current_cycle.rb) but, unlike recommendation_measures,
# were never indexed on either foreign key - every lookup by category_id,
# recommendation_id, measure_id or indicator_id is a sequential scan.
class IndexCurrentCycleJoinTables < ActiveRecord::Migration[8.0]
def change
add_index :recommendation_categories, :category_id
add_index :recommendation_categories, :recommendation_id
add_index :measure_indicators, :measure_id
add_index :measure_indicators, :indicator_id
end
end
6 changes: 5 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2026_07_11_004613) do
ActiveRecord::Schema[8.0].define(version: 2026_09_01_220117) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"

Expand Down Expand Up @@ -129,6 +129,8 @@
t.datetime "updated_at", null: false
t.integer "created_by_id"
t.bigint "updated_by_id"
t.index ["indicator_id"], name: "index_measure_indicators_on_indicator_id"
t.index ["measure_id"], name: "index_measure_indicators_on_measure_id"
t.index ["updated_by_id"], name: "index_measure_indicators_on_updated_by_id"
end

Expand Down Expand Up @@ -198,6 +200,8 @@
t.datetime "updated_at", null: false
t.integer "created_by_id"
t.bigint "updated_by_id"
t.index ["category_id"], name: "index_recommendation_categories_on_category_id"
t.index ["recommendation_id"], name: "index_recommendation_categories_on_recommendation_id"
t.index ["updated_by_id"], name: "index_recommendation_categories_on_updated_by_id"
end

Expand Down
Loading