Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

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

Merged
merged 5 commits into from
Nov 12, 2015

Conversation

erikjohnston
Copy link
Member

No description provided.

@NegativeMjark
Copy link
Contributor

Might want to have a comment referencing https://sqlite.org/optoverview.html#crossjoin

@erikjohnston
Copy link
Member Author

Done

@@ -252,12 +252,17 @@ def search_room(self, room_id, search_term, keys, limit, pagination_token=None):
" WHERE vector @@ query AND room_id = ?"
)
elif isinstance(self.database_engine, Sqlite3Engine):
# We use CROSS JOIN here to ensure we use the right indexes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth elaborating on what the right indexes are. Something like "We want to use the full text search index on event_search to extract all possible matches first, then lookup those matches in the events table to get the topological ordering. We need to use the indexes in this order because sqlite refuses to MATCH unless it uses the full text search index"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@NegativeMjark
Copy link
Contributor

LGTM

erikjohnston added a commit that referenced this pull request Nov 12, 2015
Use a (hopefully) more efficient SQL query for doing recency based room search
@erikjohnston erikjohnston merged commit 49f1758 into develop Nov 12, 2015
@erikjohnston erikjohnston deleted the erikj/search_fix_sqlite_faster branch November 19, 2015 16:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants