0

我进行了速度测试,将传统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) 

我怀疑我忽略了一些非常基本的东西?

4

2 回答 2

0

为什么要加载所有 3000 个帖子?那个基准没有意义。如果您必须加载整个表,那么使用 Solr 不会有任何区别。

于 2012-04-13T22:30:23.357 回答
0

Whitespace is significant in YAML. Are you sure the auto_commit_after_request line belongs under solr? I've seen a few examples where it falls under the development/production/test element:

development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
  auto_commit_after_request: false
于 2012-07-27T19:13:19.627 回答