2011-09-02 1 views
3

난 다음에 처음 문을 포함 내 SOLR 지수의 2 버전을 벤치마킹 :않습니다 : 흑점/solr 검색 가능한 방법 안에 아무것도 포함합니까?

searchable(:auto_index => false, :auto_remove => true, 
      :include => { :account => true, 
      :user_practice_contact => [:city], 
      :user_professional_detail => [:specialty, :subspecialties]}) do 

을 두 번째 :

searchable(:auto_index => false, :auto_remove => true) do 

내가 포함하지만 여기에 버전에 속도 범프를보기 위해 기다리고 있었다 와

버전 포함 : 결과는

Benchmark.measure { User.limit(50).each do |u|; u.index; end; Sunspot.commit; } 
    => #<Benchmark::Tms:0x1130b34e8 @real=6.8079788684845, @utime=5.05, @cstime=0.0, @cutime=0.0, @total=5.2, @label="", @stime=0.149999999999999> 

와 포함하지 않고 다음이 일을 해야하는 포함되어있는 경우

Benchmark.measure { User.limit(50).each do |u|; u.index; end; Sunspot.commit; } 
=> #<Benchmark::Tms:0x112ef0fe8 @real=6.82465195655823, @utime=4.92, @cstime=0.0, @cutime=0.0, @total=5.07, @label="", @stime=0.15> 

아무도 알고 있나요? 그리고 그렇다면 내가 잘못하고있는 것입니까? 나는 문서를 보았다 : http://outoftime.github.com/sunspot/rails/docs/ 그리고 아무런 언급이 없다.

답변

3

the API에 따르면, :include는 :

때 인덱싱 액티브 필요한 연결을로드 할 수 있습니다.

일반 Ruby 반복기의 개별 레코드를 인덱싱하므로 벤치 마크가 제대로 작동하지 않습니다. 하나의 레코드를 50 번 인덱싱 할 때 Sunspot은 열망하는로드를 전혀 활용할 수 없습니다. 대신 다음을 수행해야합니다.

Sunspot.index(User.limit(50)); 
Sunspot.commit 

아, 다음과 같은 항목이 위보다 빠르면 테스트 할 수 있습니까? 나는 정말로 알고 싶다.

Sunspot.index(User.includes(:account).limit(50)); 
Sunspot.commit 

는 또한 bug 현재 STI 모델은 :include을 무시하는 것이있다.

1

레일 로그의 SQL 쿼리를 살펴보면 검색 가능한 원인으로 :include이 색인 생성 중에 열심히로드되는 것을 볼 수 있습니다. :include on #search은 검색하는 동안 열심히로드하는 원인이됩니다.