diff options
author | Mark Haines <mark.haines@matrix.org> | 2016-07-04 19:44:55 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2016-07-04 19:44:55 +0100 |
commit | 0fb76c71ac4bdd00e7524cf11668c13754d29a08 (patch) | |
tree | 0f24365a8a18af295318d93d00a75e2a57011d1c /synapse/storage/event_push_actions.py | |
parent | Use a query that postgresql optimises better for get_events_around (diff) | |
download | synapse-0fb76c71ac4bdd00e7524cf11668c13754d29a08.tar.xz |
Use different SQL for postgres and sqlite3 for when using multicolumn indexes
Diffstat (limited to 'synapse/storage/event_push_actions.py')
-rw-r--r-- | synapse/storage/event_push_actions.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/synapse/storage/event_push_actions.py b/synapse/storage/event_push_actions.py index 5f1b6f63a9..e3e2e8083e 100644 --- a/synapse/storage/event_push_actions.py +++ b/synapse/storage/event_push_actions.py @@ -16,6 +16,8 @@ from ._base import SQLBaseStore from twisted.internet import defer from synapse.util.caches.descriptors import cachedInlineCallbacks +from synapse.types import RoomStreamToken +from .stream import lower_bound import logging import ujson as json @@ -73,6 +75,9 @@ class EventPushActionsStore(SQLBaseStore): stream_ordering = results[0][0] topological_ordering = results[0][1] + token = RoomStreamToken( + topological_ordering, stream_ordering + ) sql = ( "SELECT sum(notif), sum(highlight)" @@ -80,15 +85,10 @@ class EventPushActionsStore(SQLBaseStore): " WHERE" " user_id = ?" " AND room_id = ?" - " AND (" - " topological_ordering > ?" - " OR (topological_ordering = ? AND stream_ordering > ?)" - ")" - ) - txn.execute(sql, ( - user_id, room_id, - topological_ordering, topological_ordering, stream_ordering - )) + " AND %s" + ) % (lower_bound(token, self.database_engine, inclusive=""),) + + txn.execute(sql, (user_id, room_id)) row = txn.fetchone() if row: return { |