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

Model Eager Loading in Development is Slow

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

      With 20 model classes loading at about 50ms each, it can easily take 1000ms/req in development mode to eager load all the model classes. This adds 1000ms to each request in development mode over and above the time that would be taken by queries, views, etc. This can easily slow down development of and frustrate developers working with a Rails+Mongoid application.

      A comment in the railtie (https://github.com/mongoid/mongoid/blob/2.0.2/lib/mongoid/railtie.rb#L79) says that

      > Due to all models not getting loaded and messing up inheritance queries and indexing, we need to preload the models in order to address this.

      But that comment doesn't elaborate. In more detail, why is model eager loading in development necessary? What are the problems for which eager loading all models is the workaround? What goes wrong if models are not eager loaded? What can be done to solve these problems and make eager loading of all models unnecessary?

            Assignee:
            durran Durran Jordan
            Reporter:
            yfeldblum yfeldblum
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: