Add index for db.meter by descending timestamp

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
This commit is contained in:
vagrant
2013-07-09 02:29:36 +00:00
committed by Terri Yu
parent 1cc829732e
commit e984f28b00

View File

@@ -309,6 +309,8 @@ class Connection(base.Connection):
('timestamp', pymongo.ASCENDING),
('source', pymongo.ASCENDING),
], name='meter_idx')
self.db.meter.ensure_index([('timestamp', pymongo.DESCENDING)],
name='timestamp_idx')
# Since mongodb 2.2 support db-ttl natively
if self._is_natively_ttl_supported():