Skip to content

Commit

Permalink
Add index for db.meter by descending timestamp
Browse files Browse the repository at this point in the history
Fixes bug #1193906

Added an index for db.meter to sort by descending time stamp for class
Connection in ceilometer/storage/impl_mongodb.py

ensure_index() is used rather than create_index() to be more efficient.

This index is needed because get_samples() in
ceilometer/storage/impl_mongodb.py sorts by descending timestamp.  Without an
index, MongoDB will fail to sort if the database is too large.

Change-Id: I23070f153ce03a8d6d8c9f17f05e2d5dae38647e
(cherry picked from commit e984f28)
  • Loading branch information
terriyu authored and Eoghan Glynn committed Jul 31, 2013
1 parent 72edce2 commit 8ddafe4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ceilometer/storage/impl_mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def __init__(self, conf):
('timestamp', pymongo.ASCENDING),
('source', pymongo.ASCENDING),
], name='meter_idx')
self.db.meter.ensure_index([('timestamp', pymongo.DESCENDING)],
name='timestamp_idx')

def upgrade(self, version=None):
pass
Expand Down

0 comments on commit 8ddafe4

Please sign in to comment.