1

用户索引:

ThinkingSphinx::Index.define :user, with: :active_record
  ...
  has :group_id
end

我想获取属于组 id 的所有用户:450。该组下大约有 25000 个用户。

当我做,

User.search_for_ids({:page=>1, :per_page=>1000000, :with=>{:group_id => 450}})

返回 25000 个 id 大约需要 4 秒。

有什么我遗漏的或者我可以做些什么来更快地获取结果吗?

编辑:

参考资料:http ://www.mysqlperformanceblog.com/2013/01/15/sphinx-search-performance-optimization-attribute-based-filtering/

4

1 回答 1

1

老实说,我不确定 Sphinx 在如此大的页面大小下的性能如何......但为什么不直接从您的数据库中进行查询呢?

User.where(:group_id => 450).pluck(:id)
于 2013-10-06T11:36:38.120 回答