mongodb-query-optimizer

Diagnose slow MongoDB queries and recommend index changes using explain plans.

1|Updated Aug 22, 2025
One-click install
npx skills add https://github.com/interserver/teams-chat-bot --skill mongodb-query-optimizer-interserver
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb-query-optimizer
Source: https://github.com/interserver/teams-chat-bot/tree/main/.claude/skills/mongodb-query-optimizer
Command: npx skills add https://github.com/interserver/teams-chat-bot --skill mongodb-query-optimizer-interserver

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps you reduce slow MongoDB query times by diagnosing why queries are inefficient and recommending better indexing or query-shape changes.

Core Features & Use Cases

  • Explain-driven diagnosis: Uses explain() output and existing index metadata to identify whether the query uses indexes efficiently and where work is wasted (e.g., scans or sorts).
  • Index recommendation guidance: Recommends compound indexes that better match equality filters and sort patterns, prioritizing the highest impact fixes.
  • Atlas Performance Advisor + slow query logs: When Atlas MCP is configured, uses slow query logs and Performance Advisor suggestions to validate what to optimize across real traffic.
  • When to use it: Best for questions like “Why is this query slow?” or “How do I index this?” rather than routine query writing.

Quick Start

Ask: "Why is my MongoDB query slow, and what index should I create for it?" including the query shape and the collection/database names.

Frequently Asked Questions about mongodb-query-optimizer

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

FAQPage Schema
Why is my MongoDB query slow and doing a collection scan?

Slow MongoDB queries often result from missing or inefficient indexes, causing collection scans. Diagnosing the query with an explain plan identifies where work is wasted in scans or sorts, guiding the creation of matching indexes.

How do I find the right index to speed up slow MongoDB queries?

To speed up slow MongoDB queries, analyze the query shape and existing collection indexes. Recommending compound indexes that match equality filters and sort patterns prioritizes the highest impact fixes for query performance.

Can I use Atlas Performance Advisor to review MongoDB slow query logs?

Yes, when Atlas MCP is configured, you can review slow query logs and Performance Advisor suggestions. This validates what to optimize across real traffic to improve general cluster performance.

What information do I need to diagnose MongoDB query performance?

Diagnosing MongoDB query performance requires the query shape, database name, and collection name. The analysis uses explain plan output and existing collection index metadata to identify inefficient index usage.

Does this work with routine MongoDB query writing?

No, this is best for questions like why a query is slow or how to index a collection. It focuses on diagnosing slow query behavior and recommending index changes rather than routine query writing.