I'm definitely aware that the facets code is far from ideal currently... but there is one big limitation: there's no way to avoid a query per facet.
That said, there's definitely some ways to speed things up: * Switch to id facet queries, instead of loading *all* objects per facet query. * Make all the queries in one request (Sphinx supports this, TS doesn't yet do so). * Not instantiate objects unless necessary (Sphinx returns attribute values). Obviously, I should have done this a lot sooner. Hopefully I can make some time for it soon! :) -- Pat On 12/08/2010, at 3:16 AM, kshipley wrote: > Oy -- I need to take a step back from this for a moment. > > It appears that the patch doesn't work if a facet refers to values > from another table. In my situation, since I have > > has provider.gender, :as => :gender, :facet => true > > it's triggering the call to provider in source_objects. > > I'll see if I can patch around that and let you know if I come up with > anything. > > </stream_of_consciousness_posting> > > On Aug 11, 10:06 am, kshipley <[email protected]> wrote: >> Sorry for the double post -- apparently an :include => :provider >> argument is causing that call to fail. Since I've switched to ids, I >> probably don't need that include anymore. I'll let you know how the >> patch turns out, but would love any additional ideas around not making >> an index hit for every facet! >> >> Kyle >> >> On Aug 11, 10:01 am, kshipley <[email protected]> wrote: >> >> >> >>> James, >> >>> I tried applying your patch yesterday afternoon, but something about >>> the way my index is set up is causing a NoMethodError. Is this >>> something you came across at all? >> >>> I'm going to dive in a little bit and see if I can track down the >>> problem, but here's a stack trace if you have any ideas (starting from >>> a monkey-patched version of your patch): >> >>> undefined method `provider' for 2975727:Fixnum >> >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:109:in `block (2 levels) in >>> source_objects' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:108:in `collect' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:108:in `block in source_objects' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:107:in `each' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:107:in `source_objects' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:94:in `translate' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet.rb:75:in `value' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet_search.rb:114:in `block in add_from_results' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/search.rb:219:in `block in >>> each_with_groupby_and_count' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/search.rb:218:in `each' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/search.rb:218:in `each_with_index' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/search.rb:218:in `each_with_groupby_and_count' >>> /Users/kshipley/work/src/my_project/vendor/gems/thinking-sphinx-1.3.16/ >>> lib/thinking_sphinx/facet_search.rb:113:in `add_from_results' >>> /Users/kshipley/work/src/my_project/app/patches/thinking_sphinx/ >>> facet_search_patch.rb:30:in `block in populate' >>> /Users/kshipley/work/src/my_project/app/patches/thinking_sphinx/ >>> facet_search_patch.rb:25:in `each' >>> /Users/kshipley/work/src/my_project/app/patches/thinking_sphinx/ >>> facet_search_patch.rb:25:in `populate' >> >>> On Aug 10, 8:51 pm, James Healy <[email protected]> wrote: >> >>>> kshipley wrote: >>>>> Has anyone patched around this issue? Is there a mechanism to get >>>>> faceted results that doesn't go through the offending populate method? >> >>>> I've had similar issues and came up with the patch at [1]. Performance >>>> still isn't great, but it's better. >> >>>> I'd be interested to hear if it helps in your situation. >> >>>> -- James Healy <[email protected]> Wed, 11 Aug 2010 13:51:05 +1000 >> >>>> [1]http://groups.google.com/group/thinking-sphinx/browse_thread/thread/5... > > -- > You received this message because you are subscribed to the Google Groups > "Thinking Sphinx" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/thinking-sphinx?hl=en. > -- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
