From d1ccca51e3463618c6a0a8de2298102b69ec989a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:15:37 +0000 Subject: [PATCH] feat(perf): defer heavy columns in issue deduplication queries Optimizes `create_issue` and `get_nearby_issues` endpoints by deferring the loading of `action_plan` (JSON text), `image_path`, and `location` columns. This prevents fetching large amounts of unused data during spatial deduplication and list retrieval, reducing memory usage and database I/O. Verified that deferred fields are not accessed in the response path, preventing N+1 query regressions. Co-authored-by: RohanExploit <178623867+RohanExploit@users.noreply.github.com> --- backend/routers/issues.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/routers/issues.py b/backend/routers/issues.py index 0d862d84..90e5f75f 100644 --- a/backend/routers/issues.py +++ b/backend/routers/issues.py @@ -100,6 +100,10 @@ async def create_issue( Issue.latitude <= max_lat, Issue.longitude >= min_lon, Issue.longitude <= max_lon + ).options( + defer(Issue.action_plan), + defer(Issue.image_path), + defer(Issue.location) ).all() ) @@ -261,6 +265,10 @@ def get_nearby_issues( Issue.latitude <= max_lat, Issue.longitude >= min_lon, Issue.longitude <= max_lon + ).options( + defer(Issue.action_plan), + defer(Issue.image_path), + defer(Issue.location) ).all() nearby_issues_with_distance = find_nearby_issues(