2
使用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
方法...
您的意思是传递SELECT语句的提示,但仍然使用ActiveRecord查询语法? – Zabba 2011-06-06 19:40:58
已更新,以阐明我的需求 – 2011-06-06 20:14:33