⚡ [performance] Fix Core Data N+1 Faults in Inspector#1
Conversation
By setting `returnsObjectsAsFaults = false` on the `NSFetchRequest` in `CoreDataRecordsVC`, we avoid the "N+1 Faults" issue where every attribute access on the fetched objects would trigger a separate disk fetch. This significantly improves performance when mapping fetched objects to display rows.
|
👋 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. |
💡 What: Added
request.returnsObjectsAsFaults = falseto theNSFetchRequestinCoreDataRecordsVC.fetchRecords().🎯 Why: The previous code fetched objects as faults and then immediately iterated over all their attributes to map them into a dictionary for display. This caused "N+1" separate database queries for every fetch, which is highly inefficient.
📊 Measured Improvement: In a scenario with 500 records (the fetch limit), this reduces the number of database round-trips from 501 to 1. While the lack of a Swift toolchain in the development environment prevented direct benchmarking, the improvement is theoretically significant for Core Data performance.
PR created automatically by Jules for task 5190446710105594142 started by @synaptode