From 347d54f388396b423e762085cc463e752cb91036 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 9 Aug 2024 15:42:51 -0600 Subject: [PATCH] Chunk timeline deletes (#12900) --- frigate/events/cleanup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frigate/events/cleanup.py b/frigate/events/cleanup.py index 674833d2b..393aeea0b 100644 --- a/frigate/events/cleanup.py +++ b/frigate/events/cleanup.py @@ -194,9 +194,13 @@ class EventCleanup(threading.Thread): events_with_expired_clips = self.expire(EventCleanupType.clips) # delete timeline entries for events that have expired recordings - Timeline.delete().where( - Timeline.source_id << events_with_expired_clips - ).execute() + # delete up to 100,000 at a time + max_deletes = 100000 + deleted_events_list = list(events_with_expired_clips) + for i in range(0, len(deleted_events_list), max_deletes): + Timeline.delete().where( + Timeline.source_id << deleted_events_list[i : i + max_deletes] + ).execute() self.expire(EventCleanupType.snapshots)