-1

对于我表中的一些记录,下面的查询需要将近 300 毫秒。

TestDescription.find(:first, :conditions =>["test_point_id IS NULL AND test_info=?",file_name])

有什么办法可以提高它的性能???

谢谢!

4

1 回答 1

2

首先,删除古老的find(:first...)语法,并使用

TestDescription.where(test_point_id: nil, test_info: file_name).first

接下来,确保您在搜索的列上有索引。

于 2013-07-08T13:44:19.873 回答