Use a (hopefully) more efficient SQL query for doing recency based room search

pull/366/head
Erik Johnston 2015-11-12 14:07:25 +00:00
parent 39de87869c
commit 14a9d805b9
1 changed files with 6 additions and 4 deletions

View File

@ -253,11 +253,13 @@ class SearchStore(BackgroundUpdateStore):
)
elif isinstance(self.database_engine, Sqlite3Engine):
sql = (
"SELECT rank(matchinfo(event_search)) as rank, room_id, event_id,"
"SELECT rank(matchinfo) as rank, room_id, event_id,"
" topological_ordering, stream_ordering"
" FROM event_search"
" NATURAL JOIN events"
" WHERE value MATCH ? AND room_id = ?"
" FROM (SELECT event_id, matchinfo(event_search) FROM event_search"
" WHERE value MATCH"
" )"
" CROSS JOIN events USING (event_id)"
" WHERE room_id = ?"
)
else:
# This should be unreachable.