我进行速度测试,比较传统Post.all(...)
和太阳黑子Post.search(...)
与具有约3000条记录的表格之间的结果。在这两种情况下,加载需要12秒。一切似乎都有效,除非速度有所提高。
环境:Ruby 1.8.7,Rails 2.3.14
Sunspot.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
的Gemfile:
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)
我怀疑我忽略了一些非常基本的东西?