N+1 Query Problem After Cursor ORM Refactoring
After Cursor refactored your ORM queries, page load times increased dramatically. Database logs show hundreds of queries for operations that previously took just a few.
The AI-generated code is fetching related entities one-by-one instead of in batch, causing the classic N+1 problem.
Error Messages You Might See
Common Causes
- Removed eager loading (include/joins), forcing lazy loading in loops
- Fetching parent objects, then accessing child collections in template/code loop
- Using ORM methods inside loops instead of batch operations
- Relationship configuration changed to lazy-load by default
- Query builder include statement removed during refactoring
How to Fix It
Use eager loading: User.findAll({include: ['Posts', 'Comments']}) or joins. Batch operations outside loops. Use dataloader pattern for GraphQL. Monitor with console.time() around queries and count DB hits.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I detect N+1 problems?
Enable query logging and count queries. N+1 means 1 query + N more. Use DevTools to see query count.
Is it always better to use joins?
Joins are faster but more memory. Sometimes batch separate queries. Test both approaches.