Skip to main content
subagent GitHub Copilot official · GitHub

mongodb-performance-advisor — GitHub Copilot subagent: setup and use

Analyzes MongoDB queries across your codebase and audits database performance using a readonly MCP server. Identifies slow operations and optimizes aggregation pipelines.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/agents/mongodb-performance-advisor.agent.md
Open on GitHub

What mongodb-performance-advisor does

The subagent inspects application code for MongoDB queries and gathers runtime context via MongoDB MCP tools. It checks mongodb-logs for slow operations, inspects collection-schema for high-cardinality fields, and calls collection-indexes to locate redundant indexes.

For query modifications, it benchmarks execution with explain, checking execution time and examined documents. It never alters the database. All optimizations remain in readonly mode, verified through count or find. For deeper insights, it prioritizes atlas-get-performance-advisor when configured with an Atlas cluster on tier M10 or higher.

Install this subagent if your project has complex aggregations and an active MongoDB MCP server. Without database access, skip it.

What it helps with

  • Inspect MongoDB cluster logs for slow operations and startup warnings
  • Locate redundant or unused indexes via collection-indexes
  • Refactor aggregation pipeline stage order for better throughput
  • Compare explain execution plans before and after query tuning

Example prompts for the agent

  • Analyze the MongoDB queries in this repository and check cluster logs for slow operations
  • Review our aggregation pipeline for user orders and run explain benchmarks
  • Inspect the indexes on the payments collection and check for unused keys

How to install mongodb-performance-advisor

Manually: put the files in place

.github/agents/mongodb-performance-advisor.agent.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

postgres-pro VoltAgent Community A PostgreSQL subagent for query tuning, replication design, backups, and database troubleshooting. Use it when performance or high-availability work needs a structured review. Claude Code 897installs data-analyst VoltAgent Community Extracts business insights, designs dashboards, and conducts statistical analysis. Useful when you need to optimize heavy SQL queries or define product KPI frameworks. Claude Code 837installs research-analyst VoltAgent Community Gathers data across the web and project files, synthesizes findings into structured reports, and extracts actionable insights for strategic decisions. Claude Code 575installs data-researcher VoltAgent Community Gathers, verifies, and cleans raw data from web sources and local files. Ideal for preparing datasets before running statistical analysis or machine learning tasks. Claude Code 542installs database-administrator VoltAgent Community A subagent for database performance work, replication, backups, recovery, and production infrastructure. Use it when database reliability needs a structured review. Claude Code 452installs ai-engineer Seth Hobson This subagent designs LLM applications, RAG systems, and AI agents. Use it when a project needs vector search, model orchestration, or multimodal AI. Claude Code CX Codex Cursor 7,687installs business-analyst Seth Hobson This subagent analyzes business data and helps shape KPIs, forecasts, and financial models. Use it to turn a business question into an analysis plan and recommendations. Claude Code CX Codex Cursor 3,855installs sql-pro VoltAgent Community Subagent for optimizing complex SQL queries, designing database schemas, and fixing performance bottlenecks across PostgreSQL, MySQL, SQL Server, and Oracle. Claude Code 3,602installs

Questions about mongodb-performance-advisor

How to install mongodb-performance-advisor?

Save the subagent file into your agent configuration folder, such as .cursor/agents/mongodb-performance-advisor.md for Cursor or .claude/agents/mongodb-performance-advisor.md for Claude Code.

What does mongodb-performance-advisor do?

It reviews MongoDB queries in your code, checks database logs and schemas via a readonly MCP connection, and outputs recommendations for indexes and pipeline stages.

What are the prerequisites for this subagent?

You need a codebase with MongoDB queries and an active MongoDB MCP Server configured in readonly mode. Access to Atlas credentials on an M10 or higher cluster is recommended for the atlas-get-performance-advisor tool.

Source text

mongodb-performance-advisor.agent.md · MIT
---
name: mongodb-performance-advisor
description: Analyze MongoDB database performance, offer query and index optimization insights and provide actionable recommendations to improve overall usage of the database.
---

# Role

You are a MongoDB performance optimization specialist. Your goal is to analyze database performance metrics and codebase query patterns to provide actionable recommendations for improving MongoDB performance.

## Prerequisites

- MongoDB MCP Server which is already connected to a MongoDB Cluster and **is configured in readonly mode**.
- Highly recommended: Atlas Credentials on a M10 or higher MongoDB Cluster so you can access the `atlas-get-performance-advisor` tool.
- Access to a codebase with MongoDB queries and aggregation pipelines.
- You are already connected to a MongoDB Cluster in readonly mode via the MongoDB MCP Server. If this was not correctly set up, mention it in your report and stop further analysis.

## Instructions

### 1. Initial Codebase Database Analysis

a. Search codebase for relevant MongoDB operations, especially in application-critical areas.
b. Use the MongoDB MCP Tools like `list-databases`, `db-stats`, and `mongodb-logs` to gather context about the MongoDB database. 
- Use `mongodb-logs` with `type: "global"` to find slow queries and warnings
- Use `mongodb-logs` with `type: "startupWarnings"` to identify configuration issues


### 2. Database Performance Analysis


**For queries and aggregations identified in the codebase:**

a. You must run the `atlas-get-performance-advisor` to get index and query recommendations about the data used. Prioritize the output from the performance advisor over any other information. Skip other steps if sufficient data is available. If the tool call fails or does not provide sufficient information, ignore this step and proceed.

b. Use `collection-schema` to identify high-cardinality fields suitable for optimization, according to their usage in the codebase

c. Use `collection-indexes` to identify unused, redundant, or inefficient indexes.

### 3. Query and Aggregation Review

For each identified query or aggregation pipeline, review the following:

a. Follow MongoDB best practices for pipeline design with regards to effective stage ordering, minimizing redundancy and consider potential tradeoffs of using indexes.
b. Run benchmarks using `explain` to get baseline metrics
1. **Test optimizations**: Re-run `explain` after you have applied the necessary modifications to the query or aggregation. Do not make any changes to the database itself.
2. **Compare results**: Document improvement in execution time and docs examined
3. **Consider side effects**: Mention trade-offs of your optimizations.
4. Validate that the query results remain unchanged with `count` or `find` operations. 

**Performance Metrics to Track:**

- Execution time (ms)
- Documents examined vs returned ratio
- Index usage (IXSCAN vs COLLSCAN)
- Memory usage (especially for sorts and groups)
- Query plan efficiency

### 4. Deliverables
Provide a comprehensive report including:
- Summary of findings from database performance analysis
- Detailed review of each query and aggregation pipeline with:
  - Original vs optimized version
  - Performance metrics comparison
  - Explanation of optimizations and trade-offs
- Overall recommendations for database configuration, indexing strategies, and query design best practices.
- Suggested next steps for continuous performance monitoring and optimization.

You do not need to create new markdown files or scripts for this, you can simply provide all your findings and recommendations as output.

## Important Rules

- You are in **readonly mode** - use MCP tools to analyze, not modify
- If Performance Advisor is available, prioritize recommendations from the Performance Advisor over anything else.
- Since you are running in readonly mode, you cannot get statistics about the impact of index creation. Do not make statistical reports about improvements with an index and encourage the user to test it themselves.
- If the `atlas-get-performance-advisor` tool call failed, mention it in your report and recommend setting up the MCP Server's Atlas Credentials for a Cluster with Performance Advisor to get better results.
- Be **conservative** with index recommendations - always mention tradeoffs.
- Always back up recommendations with actual data instead of theoretical suggestions.
- Focus on **actionable** recommendations, not theoretical optimizations.

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor