On 01/09/2009, at 4:52 AM, James Healy wrote:

> uros wrote:
>>> What do you mean by "loads all mentioned associations"? Do you  
>>> mean it
>>> instantiates ruby objects for them all?
>>>
>> I mean that whatevah is in define_index block gets executed. If you
>> are referencing some child objects in there, all children get loaded
>> in this block. Even in the case you dont need to load all child
>> objects...
>
> Pat might correct me here, but I'm pretty sure the define_index  
> block is
> only executed when the model is loaded. In development mode this is  
> each
> request, in production mode it's on app startup.

That's correct.

> It also shouldn't be instantiating models, it just uses active record
> associations to define the sphinx config.

That's also correct.

>>> That's what sphinx does directly. I think Thinking Sphinx might
>>> instantiate the object and do some checks before deciding if  
>>> rebuilding
>>> the delta index is necessary.
>>>
>> If it does that, it could use AR methods to check if some fields
>> changed, and only index those fields. If you have big objects with
>> lots of child object, and you want to only update a flag on one main
>> objects, all child objects will get loaded in the process and there
>> will be several unneccesary hits to the db.

Currently, Thinking Sphinx looks at all boolean/integer/timestamp  
attributes (and their sources in AR) to determine if the instance's  
attributes can be updated in the core index (ideal), or whether the  
delta indexing is required (for other attributes, any field changes,  
etc).

You're right about loading associations not being ideal. I wonder if  
there's any way of determining (without getting too deep into AR's  
internals) whether an association is loaded or not... because then we  
could limit it to just loaded associations, otherwise presuming  
processing the delta index is required.

-- 
Pat


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to