我进行了速度测试,将传统Post.all(...)
和 Sunspot 的结果Post.search(...)
与大约 3000 条记录的表进行了比较。在这两种情况下,加载都需要 12 秒。一切似乎都正常,除了速度的任何改进。
环境:Ruby 1.8.7,Rails 2.3.14
太阳黑子.yml:
production:
solr:
hostname: localhost
port: 8984
log_level: FINEST
auto_commit_after_request: false
development:
solr:
hostname: localhost
port: 8982
log_level: INFO
auto_commit_after_request: false
test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
auto_commit_after_request: false
宝石文件:
gem "rsolr", "0.12.1"
gem "sunspot", "1.2.1"
gem "sunspot_solr", "1.3.1"
gem "sunspot_rails", "1.2.1"
控制器:
@users = User.search do
with :client_id, current_user.client.id
paginate :page => params[:page] if params[:page]
paginate :page => 1 if not params[:page]
paginate :per_page => PAGINATION_COUNT
end
看法:
concat will_paginate(@users)
我怀疑我忽略了一些非常基本的东西?