[MongoDB] add indexes in event collection
Now in event collection only ttl index existed, that means response on queries for event collection will become slower with collection growth. Additional indexes based on timestamp and event_type fields in improves this. Closes-bug: #1526793 Change-Id: I87f13262a213828e1aca5fbe60544db78999a341
This commit is contained in:
parent
512b7f0678
commit
033a2e3fd2
@ -57,6 +57,13 @@ class Connection(pymongo_base.Connection):
|
|||||||
if 'event' not in self.db.conn.collection_names():
|
if 'event' not in self.db.conn.collection_names():
|
||||||
self.db.conn.create_collection('event')
|
self.db.conn.create_collection('event')
|
||||||
# Establish indexes
|
# Establish indexes
|
||||||
|
# NOTE(idegtiarov): This indexes cover get_events, get_event_types, and
|
||||||
|
# get_trait_types requests based on event_type and timestamp fields.
|
||||||
|
self.db.event.create_index(
|
||||||
|
[('event_type', pymongo.ASCENDING),
|
||||||
|
('timestamp', pymongo.ASCENDING)],
|
||||||
|
name='event_type_idx'
|
||||||
|
)
|
||||||
ttl = cfg.CONF.database.event_time_to_live
|
ttl = cfg.CONF.database.event_time_to_live
|
||||||
impl_mongodb.Connection.update_ttl(ttl, 'event_ttl', 'timestamp',
|
impl_mongodb.Connection.update_ttl(ttl, 'event_ttl', 'timestamp',
|
||||||
self.db.event)
|
self.db.event)
|
||||||
|
Loading…
Reference in New Issue
Block a user