Rails 2.3.4 を使用して、データベース オプティマイザにヒントを渡すことは可能ですか? テスト目的で特定のインデックスの使用を強制できるようにしたいと考えています。
私は持っています(レガシーコード、はい、においがします):
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')
}
条項force index for join(profile_date_state_activity)
の最後までタックできるようにしたいと考えています。FROM
それができない場合は、方法が必要average_by_sql
です...