query-optimization

Optimize Node.js database queries with indexing, EXPLAIN ANALYZE, and cursor pagination.

2|1|Updated Nov 13, 2025
One-click install
npx skills add https://github.com/MolcajeteAI/plugin --skill query-optimization-molcajeteai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-optimization
Source: https://github.com/MolcajeteAI/plugin/tree/main/deprecated/tech-stacks/js/node/skills/query-optimization
Command: npx skills add https://github.com/MolcajeteAI/plugin --skill query-optimization-molcajeteai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses slow database query performance, high CPU usage, and inefficient data retrieval patterns like N+1 queries, helping developers optimize their applications.

Core Features & Use Cases

  • N+1 Query Prevention: Provides solutions using include and the DataLoader pattern.
  • Index Strategies: Guides on creating effective database indexes for various query types.
  • Query Analysis: Demonstrates how to use EXPLAIN ANALYZE and query logging.
  • Pagination Optimization: Offers both offset and cursor pagination examples.
  • Efficient Data Fetching: Emphasizes selecting only necessary columns and batch operations.

Quick Start

Use the query-optimization skill to prevent N+1 queries in your Node.js application by implementing the DataLoader pattern.

Frequently Asked Questions about query-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix the N+1 query problem in my Node.js application?

To fix the N+1 query problem in Node.js, you can use ORM `include` statements or implement the DataLoader pattern to batch database queries and efficiently fetch related data.

How do I use EXPLAIN ANALYZE to troubleshoot slow database queries?

You can use `EXPLAIN ANALYZE` and query logging to analyze slow database queries, revealing execution bottlenecks so you can apply proper indexing and optimize data retrieval strategies.

Does this database optimization guidance work with Prisma and Drizzle ORMs?

Yes, the database optimization strategies explicitly support Prisma and Drizzle ORMs, providing specific examples for efficient data fetching, indexing, and query performance improvements in Node.js.

What is the best way to implement cursor pagination for large datasets?

Cursor pagination is an efficient strategy for large datasets, offering examples alongside offset pagination to improve application responsiveness and reduce database load during data retrieval.

How do I create effective database indexes for query optimization?

Effective database indexing requires analyzing query patterns to build targeted indexes, which drastically reduces lookup times and lowers CPU usage during inefficient data retrieval operations.