From 3365117151217f0ea96291aabce222f8b58bd850 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 1 Mar 2017 10:21:30 +0000 Subject: Clobber old device list stream entries --- synapse/storage/devices.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py index 7b5903bf8e..f9ed18d2aa 100644 --- a/synapse/storage/devices.py +++ b/synapse/storage/devices.py @@ -546,6 +546,16 @@ class DeviceStore(SQLBaseStore): host, stream_id, ) + # Delete older entries in the table, as we really only care about + # when the latest change happened. + txn.executemany( + """ + DELETE FROM device_lists_stream + WHERE user_id = ? AND device_id = ? AND stream_id < ? + """, + [(user_id, device_id, stream_id) for device_id in device_ids] + ) + self._simple_insert_many_txn( txn, table="device_lists_stream", -- cgit 1.4.1