perf: Optimize snapshot database queries (fix N+1 issue)#38
perf: Optimize snapshot database queries (fix N+1 issue)#38matthewro7263-hub wants to merge 3 commits into
Conversation
… for storyboard panels This resolves the N+1 issue in snapshot creation, trash integrity scan, and trash item fetching.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This resolves the N+1 issue in snapshot creation, trash integrity scan, and trash item fetching.
|
Review notes before merge:
Aligned with keep-it-free goal: ✅ pure perf win, reduces server cost. |
This resolves the N+1 issue in snapshot creation, trash integrity scan, and trash item fetching.
|
Going to close this one out — it's got merge conflicts against current main, and the same N+1 area was already addressed by the more recent #62 (snapshot panel loading) and the still-open #65 (project archive export). Rather than rebasing 3-week-old changes, suggest closing this and letting the newer PRs cover it. Nice benchmarks though. |
|
Closing as duplicate — the same N+1 fix landed in #71. |
💡 What: Replaced the
flatMappattern for fetching storyboard panels with a singleinArrayquery.🎯 Why: The previous approach executed a separate database query for every single storyboard returned from the project (an N+1 query problem). Fetching all panel rows in a single batch using the
INclause dramatically reduces round-trips and SQLite overhead.📊 Measured Improvement:
In a benchmark with 100 storyboards (10 panels each, totaling 1000 panels fetched):
inArray: ~4.3 - 4.5 msPR created automatically by Jules for task 9755194764164504910 started by @matthewro7263-hub