User Cursor.__iter__ instead of fetchall

This prevents unnecessary construction of lists
This commit is contained in:
Erik Johnston 2017-03-23 17:53:49 +00:00
parent 59358cd3e7
commit 00957d1aa4
16 changed files with 41 additions and 42 deletions

View file

@ -333,13 +333,12 @@ class DeviceStore(SQLBaseStore):
txn.execute(
sql, (destination, from_stream_id, now_stream_id, False)
)
rows = txn.fetchall()
if not rows:
return (now_stream_id, [])
# maps (user_id, device_id) -> stream_id
query_map = {(r[0], r[1]): r[2] for r in rows}
query_map = {(r[0], r[1]): r[2] for r in txn}
if not query_map:
return (now_stream_id, [])
devices = self._get_e2e_device_keys_txn(
txn, query_map.keys(), include_all_devices=True
)