Optimizing GRDB in Todoist for iOS
Article Summary
Todoist's iOS app became nearly unusable for some users after migrating from Realm to GRDB. The culprit? A SQL query generating 128,136 intermediate rows from just 399 actual records.
The Todoist iOS team shares their deep-dive debugging journey after their GRDB migration caused performance complaints. This is a masterclass in performance optimization—from reproducing issues on slow devices to using Instruments, LLMs, and SQL analysis to find the root cause.
Key Takeaways
- LEFT JOINs with multiple associations created Cartesian products: 200 × 100 × 30 = 600K rows
- Switching from JOINs to subqueries delivered 90-99% speed improvement in performance tests
- Low Power Mode on iPhone 15 Pro was slower than normal iPhone 12
- OSSignposter intervals made Instruments analysis dramatically easier to navigate
- Claude helped identify the intermediate row explosion by suggesting COUNT(*) debugging
Critical Insight
Replacing GRDB's annotated LEFT JOINs with subqueries for aggregate counts eliminated the Cartesian product problem and improved performance by up to 99%.