Commit f438aef9aae1e8ff08de1458406a03c6f899f018

Authored by Daniel Beardsley
1 parent 14f93809
Exists in master and in 1 other branch production

Drastically speed up Errbit

Enable the identity map for Mongoid. This allows subsequent finds for
the same object to skip the DB and use an in-memory store of all
retrieved records.

In many cases this reduces the number of DB queries from _hundreds_ to a
few tens.

This is particularly noticable when showing lists of problems.
Previously each `problem.app` reference caused a Apo.find() using the
`app_id`, now it's an in-memory lookup.
config/application.rb
... ... @@ -48,6 +48,9 @@ module Errbit
48 48 g.fixture_replacement :fabrication
49 49 end
50 50  
  51 + # Enable the mongoid identity map for performance
  52 + Mongoid.identity_map_enabled = true
  53 +
51 54 # IssueTracker subclasses use inheritance, so preloading models provides querying consistency in dev mode.
52 55 config.mongoid.preload_models = true
53 56  
... ...
config/mongoid.example.yml
... ... @@ -9,6 +9,8 @@
9 9  
10 10 defaults: &defaults
11 11 host: localhost
  12 + identity_map_enabled: true
  13 +
12 14 # slaves:
13 15 # - host: slave1.local
14 16 # port: 27018
... ...
config/mongoid.mongohq.yml
... ... @@ -6,3 +6,4 @@
6 6  
7 7 production:
8 8 uri: <%= ENV['MONGOHQ_URL'] %>
  9 + identity_map_enabled: true
... ...
config/mongoid.mongolab.yml
... ... @@ -6,3 +6,4 @@
6 6  
7 7 production:
8 8 uri: <%= ENV['MONGOLAB_URI'] %>
  9 + identity_map_enabled: true
... ...