LaunchKit · 2026
Back to skills

mongodb-query-optimizer

officialdata

Diagnoses slow MongoDB queries and recommends indexes based on explain plans, existing collection indexes, and Atlas Performance Advisor output.

Setup & Installation

npx skills add https://github.com/mongodb/agent-skills --skill mongodb-query-optimizer
or paste the link and ask your coding assistant to install it
https://github.com/mongodb/agent-skills/tree/main/skills/mongodb-query-optimizer
View on GitHub

What This Skill Does

Diagnoses slow MongoDB queries and recommends indexes based on explain plans, existing collection indexes, and Atlas Performance Advisor output. Follows the ESR rule (Equality, Sort, Range) for compound index suggestions and prefers index coverage over query rewrites.

It pulls real explain() stats and Performance Advisor data from your cluster instead of guessing from the query shape, so index suggestions match actual selectivity and workload.

When to use it

  • Finding why a find() with sort is doing an in-memory SORT stage
  • Picking the right field order for a compound index on a filter+sort query
  • Reviewing Atlas Performance Advisor slow query logs from the last 24 hours
  • Deciding which redundant indexes to drop on a collection near the 20-index limit
  • Fixing a query that scans 50K keys but returns 100 documents