Poor perfomance finding ids in mongodb using mongoid and rails 3 -


i'm having poor performance doing model.find(array_of_ids) in mongodb using mongoid drive, , can't understand why.

relevant code:

ids = get_ids() #get array of 137 _ids topic model. topic.find(ids) #find data, take 4 seconds it. 

_id field auto indexed, don't need manual configuration.

so, why slow?

please ask if need more explanation , sorry poor english.

seems got solution.

i wanna add on.

if ids can reach 137, think should store relation in topic collection instead. other way around. query be

topic.where(:id => self.topic_id) 

where self refers record of model.

it has_many , belongs_to relationship.

mongodb ability store array, not mean many (137) records associated other model can store way. relational method better. put in array if data type not related other model/collection. example, topic tag "trendy, teen, childish, cheesy, etc not have predefined tag, instead, defined users . opportunity in using array feature mongodb.

for case array contains topic lists, topics data defined in topic collection, relational model should have been used.

just suggestion, please not vote me down.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -