Using rails 2.3.4, is it possible to pass a hint to the database optimizer? I would like to be able to force the use of a particular index for testing purposes.
I have (legacy code, yes it smells) :
with_exclusive_scope {
succeeded.average(:elapsed,
:conditions => ["date between ? and ? ", month_start, month_end],
:joins =>["LEFT OUTER JOIN update_phases proot on (updates.id=proot.update_id AND proot.phase_id=#{UpdatePhaseType.find_by_name("update").id} and proot.started_at between '#{month_start.to_s(:db)}' and '#{month_end.to_s(:db)}')",
"INNER JOIN profiles ON updates.profile_id = profiles.id and profiles.customer_instance_id=#{customer_instance.id}"],
:group =>'date', :order =>'date')
}
and would like to be able to tack on force index for join(profile_date_state_activity)
to the end of the FROM
clause.
Failing that, I need an average_by_sql
method...