From 4bc5f4f159df9c92c77f1851aac20ef1cd7bcee3 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 9 Apr 2026 21:25:48 -0500 Subject: [PATCH] use subquery for timeline lookup to avoid SQLite variable limit --- frigate/util/object.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frigate/util/object.py b/frigate/util/object.py index 7f38438f43..7c7edc10c5 100644 --- a/frigate/util/object.py +++ b/frigate/util/object.py @@ -62,11 +62,12 @@ def get_camera_regions_grid( .where((Event.false_positive == None) | (Event.false_positive == False)) .where(Event.start_time > last_update) ) - valid_event_ids = [e["id"] for e in events.dicts()] - logger.debug(f"Found {len(valid_event_ids)} new events for {name}") + + event_count = events.count() + logger.debug(f"Found {event_count} new events for {name}") # no new events, return as is - if not valid_event_ids: + if event_count == 0: return grid new_update = datetime.datetime.now().timestamp() @@ -78,7 +79,7 @@ def get_camera_regions_grid( Timeline.data, ] ) - .where(Timeline.source_id << valid_event_ids) + .where(Timeline.source_id << events) .limit(10000) .dicts() )