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.
12 lines
177 B
Ruby
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
|