Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-393

eager loading feature

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.2.0
    • Affects Version/s: None
    • Component/s: None

      I add the eager loading feature for mongoid, just like ActiveRecord3, so you can use such syntax <code>Post.limit(20).includes(:person).each

      { |post| puts post.person.name }

      </code>.

      ActiveRecord3 has two options for eager loading, one is JOIN, the other is to use two sql queries. As mongodb doesn't support JOIN, so I just implement eager loading as two queries for mongoid.

      I also did a benchmark for eager loading, about 20% improvement, http://gist.github.com/619142

            Assignee:
            Unassigned Unassigned
            Reporter:
            flyerhzm Richard Huang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: