diff options
author | Erik Johnston <erikj@jki.re> | 2017-03-24 11:40:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 11:40:08 +0000 |
commit | 57cfa513f5ff939d88ebb3a213d977517395a631 (patch) | |
tree | 6e658aa7007fd8f890a631c5ea8c654b721d375d /synapse/storage/devices.py | |
parent | Merge pull request #2055 from matrix-org/dbkr/fix_add_msisdn_requestToken (diff) | |
parent | Replace some calls to cursor_to_dict (diff) | |
download | synapse-57cfa513f5ff939d88ebb3a213d977517395a631.tar.xz |
Merge pull request #2054 from matrix-org/erikj/user_iter_cursor
Reduce some CPU work on DB threads
Diffstat (limited to 'synapse/storage/devices.py')
-rw-r--r-- | synapse/storage/devices.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py index e545b62e39..6beeff8b00 100644 --- a/synapse/storage/devices.py +++ b/synapse/storage/devices.py @@ -333,13 +333,12 @@ class DeviceStore(SQLBaseStore): txn.execute( sql, (destination, from_stream_id, now_stream_id, False) ) - rows = txn.fetchall() - if not rows: + # maps (user_id, device_id) -> stream_id + query_map = {(r[0], r[1]): r[2] for r in txn} + if not query_map: return (now_stream_id, []) - # maps (user_id, device_id) -> stream_id - query_map = {(r[0], r[1]): r[2] for r in rows} devices = self._get_e2e_device_keys_txn( txn, query_map.keys(), include_all_devices=True ) |