Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:28:15+00:00 2026-06-05T21:28:15+00:00

I benchmarked 2 version of my solr index the first with the following include

  • 0

I benchmarked 2 version of my solr index the first with the following include statement:

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

The second:

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

I was expecting to see a speed bump on the version with includes but here is the outcome:

version with includes:

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>

and without the includes:

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> 

Does anybody know if the includes are supposed to work? And if so, am I doing it wrong?
I looked at the docs: http://outoftime.github.com/sunspot/rails/docs/ and see no mention of that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:28:17+00:00Added an answer on June 5, 2026 at 9:28 pm

    According to the API, :include will:

    allow ActiveRecord to load required associations when indexing.

    Your benchmark does not work properly because you are indexing individual records in an ordinary Ruby iterator. As you are indexing a single record 50 times, Sunspot wouldn’t be able to utilize the eager loading at all. Instead you should do:

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

    Oh and could you test if the following is faster than above? I really want to know.

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

    Also there is a bug currently that STI models will ignore the :include.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered the following error while running rake db:migrate --trace . my rails version
I'm having difficulties updating RubyGems from version 1.1.1 to newest. I've tried the following:
First, a bit of a background. There are many various comparisons of distributed version
I have following - Gem Version - 1.3.2 Ruby Version - ruby 1.8.7 (2008-08-11
I recently read in a presentation on Scribd that Facebook had benchmarked a variety
First of all, it's great. However, I came across a situation where my benchmarks
I have the following table structure, A -< B represents one A can have
I'm using an old version of python on an embedded platform ( Python 1.5.2+
I'm having a contest with another student to make the fastest version of our
I'm on Ubuntu 11.10 using ghc version 7.0.3.20110330, running current-version updates of nvidia display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.