diff options
author | Erik Johnston <erik@matrix.org> | 2016-04-22 11:23:49 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-04-22 11:23:49 +0100 |
commit | 64ec3493c1203747ab1b77a1f5b477a5f897613d (patch) | |
tree | a57b369c4b857ed1ef353ba7aedfcfcb431b9ec9 /synapse/storage/room.py | |
parent | Merge pull request #687 from nikriek/jwt-fix (diff) | |
parent | Update port script (diff) | |
download | synapse-64ec3493c1203747ab1b77a1f5b477a5f897613d.tar.xz |
Merge pull request #745 from matrix-org/erikj/search-index
Optimise event_search in postgres
Diffstat (limited to 'synapse/storage/room.py')
-rw-r--r-- | synapse/storage/room.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/synapse/storage/room.py b/synapse/storage/room.py index 9be977f387..70aa64fb31 100644 --- a/synapse/storage/room.py +++ b/synapse/storage/room.py @@ -169,20 +169,28 @@ class RoomStore(SQLBaseStore): def _store_event_search_txn(self, txn, event, key, value): if isinstance(self.database_engine, PostgresEngine): sql = ( - "INSERT INTO event_search (event_id, room_id, key, vector)" - " VALUES (?,?,?,to_tsvector('english', ?))" + "INSERT INTO event_search" + " (event_id, room_id, key, vector, stream_ordering, origin_server_ts)" + " VALUES (?,?,?,to_tsvector('english', ?),?,?)" + ) + txn.execute( + sql, + ( + event.event_id, event.room_id, key, value, + event.internal_metadata.stream_ordering, + event.origin_server_ts, + ) ) elif isinstance(self.database_engine, Sqlite3Engine): sql = ( "INSERT INTO event_search (event_id, room_id, key, value)" " VALUES (?,?,?,?)" ) + txn.execute(sql, (event.event_id, event.room_id, key, value,)) else: # This should be unreachable. raise Exception("Unrecognized database engine") - txn.execute(sql, (event.event_id, event.room_id, key, value,)) - @cachedInlineCallbacks() def get_room_name_and_aliases(self, room_id): def f(txn): |