0

I ran speed tests comparing the results between the traditional Post.all(...) and Sunspot's Post.search(...) against a table with about 3000 records. In both cases, it takes 12 seconds to load. Everything seems to work, execept any improvement in speed.

Env: 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"

Controller:

 @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

View:

concat will_paginate(@users) 

I suspect I've overlooked something quite fundamental?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
iamtoc
  • 1,569
  • 4
  • 17
  • 24
  • Solr server has been started, restarted, and re-indexed. File sizes in the solr folder of the rails root indicate indexing was successful I assume?. Same speed though. – iamtoc Apr 13 '12 at 22:29

2 Answers2

0

Why would you want to load all 3000 posts? That benchmark doesn't make sense. If you have to load the entire table it will not make any difference if you're using Solr.

aledalgrande
  • 5,167
  • 3
  • 37
  • 65
  • I absolutely don't want to load the entire table. I thought thats what pagination was all about. What can I do to only load the 30 records per page per PAGINATION_COUNT. From what it looks like, it downloads everything in the table. When will_paginate didn't seem to solve this, I turned to sunspot. Like I say, I'm not getting something very fundamental. – iamtoc Apr 13 '12 at 22:31
  • You say it's taking 12 seconds to load a page with 30 records in the first case: are you using will_paginate to paginate with activerecord? You can also use it in combination with Solr. – aledalgrande Apr 13 '12 at 22:36
  • Same results with Solr pagination. – iamtoc Apr 13 '12 at 23:22
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
George Armhold
  • 30,824
  • 50
  • 153
  • 232