Files
ubicloud/migrate/20240418_add_semaphore_strand_index.rb
Daniel Farina ed670156e4 Add migration to index semaphore.strand_id
Looking at our hot queries (i.e. frequency * duration = long), it
appears we were seq scanning and disqualifying nearly all `semaphore`
records running a query like:

     SELECT * FROM "semaphore" WHERE ("strand_id" = $1)

The result was excessive consumed CPU time.

The use of `CREATE INDEX CONCURRENTLY` is excessive, but it makes one
of our inherited RuboCop rules happy.  Maybe I'll disable that rule
later.
2024-04-18 18:38:04 -07:00

12 lines
177 B
Ruby

# frozen_string_literal: true
Sequel.migration do
no_transaction
change do
alter_table(:semaphore) do
add_index :strand_id, concurrently: true
end
end
end