documentdb-query-optimizer
Help with DocumentDB/MongoDB query optimization and indexing for Azure DocumentDB.
Skill by AzureOfficial
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/azure-documentdb-query-optimizer
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: cloud, writing, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/documentdb-query-optimizer
Tools it pre-approves 1
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
mcp__documentdb__*
What's inside
- Skill name
documentdb-query-optimizer- Description
- Help with DocumentDB/MongoDB query optimization and indexing for Azure DocumentDB. Use only when the user asks for optimization or performance: "How do I optimize this query?", "How do I index this?", "Why is this query slow?", "Can you fix my slow queries?", etc. Do not invoke for general query writing unless user asks for performance or index help. Prefer indexing as optimization strategy. Use DocumentDB MCP when available.
- License
- MIT
- Allowed tools
- mcp__documentdb__*
- Instructions
- 268 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- name: "documentdb-query-optimizer" does not match folder "query-optimizer"
Files (3)
- SKILL.md
- core-indexing-principles.md · references/
- index-support-queries.md · references/
SKILL.md (first lines)
# DocumentDB Query Optimizer
## When This Skill Is Invoked
Invoke **only** when the user wants:
- Query/index **optimization** or **performance** help
- **Why** a query is slow or **how to speed it up**
- **Slow queries** on their cluster and/or **how to optimize them**
- Index recommendations or index review
Do **not** invoke for routine query authoring unless the user has requested help
with optimization, slow queries, or indexing.
## High Level Workflow
### Help with a Specific Query
If the user is asking about a particular query:
1. Use `list_indexes` (MCP) or `db.<coll>.getIndexes()` (mongosh) to get existing indexes on the collection
2. Use `explain_operation` (MCP) or `.explain("executionStats")` (mongosh)
to get explain output with execution stats
3. Use `find_documents` (MCP) or `db.<coll>.findOne()` (mongosh) to fetch a sample document to understand the
schema
Then make an optimization suggestion based on collected information and best
practices from the reference files. Prefer creating an index that fully covers
the query if possible.
### General Performance Help
If the user wants to examine slow queries or is looking for general performance
suggestions (not regarding any particular query):
1. Use `list_databases` (MCP) or `show dbs` (mongosh) to understand the database structure
2. Use `get_statistics` with scope "collection" (MCP) or `db.collection.stats()` (mongosh) to identify large collections
3. Use `get_statistics` with scope "index" (MCP) or `db.collection.aggregate([{$indexStats:{}}])` (mongosh) to check existing index usage
4. Use `current_ops` (MCP) or `db.currentOp()` (mongosh) to see currently running operations
5. Suggest reviewing the most-used collections for missing indexes
## MCP Tools Available
When DocumentDB MCP server is connected, these tools are available:
| Tool name (exact) | Description |
| :--- | :--- |
| `list_indexes` | List all indexes on a collection — check if the query can use an existing index |
| `explain_operation` | Run explain with executionStats for any operation (find, aggregate, count) |
| `find_documents` | Fetch sample documents to understand schema — use with limit=1 |
| `get_statistics` | Get collection or index statistics (use scope: "collection" or "index") |
| `current_ops` | Get currently running database operations |
| `create_index` | Create a new index (only after user approval) |
| `drop_index` | Drop an existing index (only after user approval) |
| `sample_documents` | Sample random documents from a collection |
## Local mongosh Commands (No MCP Required)
All diagnostic operations can be performed directly via mongosh. Use these when
MCP is not available or for quick ad-hoc diagnostics:
```javascript
// Explain a find query
db.collection.find({filter}).explain("executionStats")
// Explain an aggregation pipeline
db.collection.aggregate([{$match:...}, {$group:...}]).explain("executionStats")
// Explain a count
db.runCommand({explain: {count: "collection", query: {filter}}, verbosity: "executionStats"})
// Collection statistics
db.collection.stats()
// List indexes
db.collection.getIndexes()
// Index usage statistics
db.collection.aggregate([{$indexStats: {}}])
// Sample documents
db.collection.aggregate([{$sample: {size: 3}}])
// Currently running operations
db.currentOp()
```
## Load References
Before beginning diagnosis and recommendation, load reference files.
Always load:
- `references/core-indexing-principles.md`
## Diagnostic Workflow
### Step 1: Gather Information
For a specific query, run these tools:
**Via MCP (when connected):**
```
list_indexes({ db_name: "<db>", collection_name: "<coll>" })
```
```
explain_operation({
db_name: "<db>",
collection_name: "<coll>",
operation: {
find: "<coll>",
filter: <filter>,
sort: <sort>,
projection: <projection>,
limit: <n>
}
})
```From Azure/documentdb-agent-kit, MIT.
More from Azure/documentdb-agent-kit
- 0.660score
documentdb-data-modeling
AzureOfficial
Data modeling patterns for Azure DocumentDB — embed vs reference, 16 MB document limit, denormalization for read-heavy workloads, schema versioning.
SkillBFreshness: B★ 6Claude Code +9 - 0.608score
documentdb-azure-deployment
AzureOfficial
Deploy an Azure DocumentDB cluster (`Microsoft.DocumentDB/mongoClusters`) end-to-end — Bicep (primary), Azure CLI one-shot, Terraform, or portal.
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-full-text-search
AzureOfficial
Full-text search best practices for Azure DocumentDB using the `createSearchIndexes` command and `$search` aggregation stage — BM25 keyword scoring, fuzzy…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-high-availability
AzureOfficial
High availability, business-continuity, and disaster-recovery best practices for Azure DocumentDB — enabling in-region HA with availability zones (99.99%…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-indexing
AzureOfficial
Index-type selection and shape guidance for Azure DocumentDB — when to use single-field, compound (ESR), multikey, wildcard, hashed, 2dsphere, TTL, and vector…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-vector-search
AzureOfficial
Vector search best practices for Azure DocumentDB using `cosmosSearch` — choosing between DiskANN / HNSW / IVF, creating indexes, tuning `lBuild` / `lSearch`…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-connection
AzureOfficial
Optimize MongoDB client connection configuration (pools, timeouts, patterns) for Azure DocumentDB.
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-mcp-setup
AzureOfficial
Guide users through installing and configuring the DocumentDB MCP server for Azure DocumentDB.
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-natural-language-querying
AzureOfficial
Generate read-only DocumentDB/MongoDB queries (find) or aggregation pipelines using natural language, with collection schema context and sample documents.
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-sharding
AzureOfficial
Horizontal sharding (partitioning) for Azure DocumentDB collections — when to shard vs stay single-shard, how to pick a shard key for read-heavy vs…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-storage
AzureOfficial
Storage configuration guidance for Azure DocumentDB — when and how to use Premium SSD v2 high-performance storage, IOPS/bandwidth caps that are gated by…
SkillCFreshness: C★ 6Claude Code +9 - 0.601score
documentdb-query-optimization
AzureOfficial
Query and aggregation-pipeline optimization rules for Azure DocumentDB — using `explain("executionStats")` to verify index usage and avoid `COLLSCAN`.
SkillCFreshness: C★ 6Claude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 6
- Forks
- 12
- Open issues
- 5
- Last commit (this folder)
- Jul 31, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Azure/documentdb-agent-kit
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from Azure
- 0.660score
documentdb-data-modeling
AzureOfficial
Data modeling patterns for Azure DocumentDB — embed vs reference, 16 MB document limit, denormalization for read-heavy workloads, schema versioning.
SkillBFreshness: B★ 6Claude Code +9 - 0.608score
documentdb-azure-deployment
AzureOfficial
Deploy an Azure DocumentDB cluster (`Microsoft.DocumentDB/mongoClusters`) end-to-end — Bicep (primary), Azure CLI one-shot, Terraform, or portal.
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-connection
AzureOfficial
Optimize MongoDB client connection configuration (pools, timeouts, patterns) for Azure DocumentDB.
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-high-availability
AzureOfficial
High availability, business-continuity, and disaster-recovery best practices for Azure DocumentDB — enabling in-region HA with availability zones (99.99%…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-full-text-search
AzureOfficial
Full-text search best practices for Azure DocumentDB using the `createSearchIndexes` command and `$search` aggregation stage — BM25 keyword scoring, fuzzy…
SkillCFreshness: C★ 6Claude Code +9 - 0.607score
documentdb-indexing
AzureOfficial
Index-type selection and shape guidance for Azure DocumentDB — when to use single-field, compound (ESR), multikey, wildcard, hashed, 2dsphere, TTL, and vector…
SkillCFreshness: C★ 6Claude Code +9
Cite this page
documentdb-query-optimizer skill. Agent Mart. https://agentmart.dev/skills/azure-documentdb-query-optimizer (last updated 2026-10-24)