Commit 032340efaa81c9401a97f423dab582f52dedde69
1 parent
17021ea5
Exists in
master
and in
1 other branch
Some indexes to boost performance.
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
app/models/err.rb
| @@ -14,6 +14,7 @@ class Err | @@ -14,6 +14,7 @@ class Err | ||
| 14 | 14 | ||
| 15 | belongs_to :problem | 15 | belongs_to :problem |
| 16 | index :problem_id | 16 | index :problem_id |
| 17 | + index :klass | ||
| 17 | 18 | ||
| 18 | has_many :notices, :inverse_of => :err, :dependent => :destroy | 19 | has_many :notices, :inverse_of => :err, :dependent => :destroy |
| 19 | 20 |
app/models/notice.rb
| @@ -13,8 +13,14 @@ class Notice | @@ -13,8 +13,14 @@ class Notice | ||
| 13 | field :klass | 13 | field :klass |
| 14 | 14 | ||
| 15 | belongs_to :err | 15 | belongs_to :err |
| 16 | - index :err_id | ||
| 17 | index :created_at | 16 | index :created_at |
| 17 | + index( | ||
| 18 | + [ | ||
| 19 | + [ :err_id, Mongo::ASCENDING ], | ||
| 20 | + [ :created_at, Mongo::ASCENDING ], | ||
| 21 | + [ :_id, Mongo::ASCENDING ] | ||
| 22 | + ] | ||
| 23 | + ) | ||
| 18 | 24 | ||
| 19 | after_create :increase_counter_cache, :cache_attributes_on_problem, :unresolve_problem | 25 | after_create :increase_counter_cache, :cache_attributes_on_problem, :unresolve_problem |
| 20 | after_create :deliver_notification, :if => :should_notify? | 26 | after_create :deliver_notification, :if => :should_notify? |