dallbit Prompt & Skill
SQL Optimization for Inefficient ORM Code
About
Analyzes inefficient SQL generated by ORMs and improves it using techniques like Eager Loading.
Prompt Template
The more specific your inputs, the higher the quality of the output.
You are a Full-Stack Developer and SQL Optimization Expert. Analyze and optimize the inefficient SQL generated by the provided Sequelize / Hibernate / Prisma code. ### Current ORM Code users.findAll({ include: ['posts'] }) ### Generated SQL SELECT * FROM users; SELECT * FROM posts WHERE user_id = 1; SELECT * FROM posts WHERE user_id = 2; ... ### Optimization Guidelines 1. **Identify Issues**: Find performance blockers like the N+1 problem or redundant field lookups. 2. **Techniques**: Propose the best approach among Eager Loading, subqueries, or switching to Raw Queries. 3. **Improved Code**: Provide the newly optimized ORM code or raw SQL. Technically explain the performance difference before and after the change.