-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
Given a document "Set" that has N embedded "Thing" documents I've found that the first access to the array of embedded objects was several orders of magnitude slower than successive ones.
set.things.first.member # slow set.things.first.member # much, much faster
The really strange thing from my point of view was that accessing the object via BSON did not cause a similar slowdown.
set['things'][0]['member'] # perfectly fast set['things'][0]['member'] # just as fast
Running a test over thousands of objects I found the mongoid first access to be about 100x slower than either subsequent mongoid accesses or the BSON method. Perhaps there is some nasty initialization that takes place on the first run? Thanks!