Add an index to event_search

- to make the purge API quicker
This commit is contained in:
Richard van der Hoff 2017-05-11 11:57:02 +01:00
parent 29ded770b1
commit baafb85ba4
3 changed files with 35 additions and 3 deletions

View file

@ -207,6 +207,17 @@ class EventsStore(SQLBaseStore):
where_clause="contains_url = true AND outlier = false",
)
# an event_id index on event_search is useful for the purge_history
# api. Plus it means we get to enforce some integrity with a UNIQUE
# clause
self.register_background_index_update(
"event_search_event_id_idx",
index_name="event_search_event_id_idx",
table="event_search",
columns=["event_id"],
unique=True,
)
self._event_persist_queue = _EventPeristenceQueue()
def persist_events(self, events_and_contexts, backfilled=False):