forked from fixin.me/fixin.me
MeasurementsController#index orders by taken_at desc; without an index this scan grows linearly with the readout count. The composite index on (user_id, taken_at) covers both the implicit user_id filter from the association scope and the ORDER BY clause. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7 lines
175 B
Ruby
7 lines
175 B
Ruby
class AddTakenAtToReadouts < ActiveRecord::Migration[7.2]
|
|
def change
|
|
add_column :readouts, :taken_at, :datetime
|
|
add_index :readouts, [:user_id, :taken_at]
|
|
end
|
|
end
|