fcakyon/claude-codex-settings / plugins/mongodb-skills/skills/mongodb-query-optimizer
mongodb-query-optimizer
VerifiedHelp with MongoDB query optimization and indexing. 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?", "What are the slow queries on my cluster?", etc. Do not invoke for general MongoDB query writing unless user asks for performance or index help. Prefer indexing as optimization strategy. Use MongoDB MCP when available.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.1 KB |
| references/aggregation-optimization.md | markdown | 6.6 KB |
| references/antipattern-examples.md | markdown | 2.5 KB |
| references/core-indexing-principles.md | markdown | 4.2 KB |
| references/update-query-examples.md | markdown | 1.1 KB |
references/update-query-examples.md
View on GitHub# Update Query Examples
## replaceOne vs. updateOne with $replaceWith
**Bad** — Full document replacement generates a large oplog entry:
```javascript
db.coll.replaceOne({ _id: X }, entireNewDocument)
```
**Good** — Use aggregation-based update to generate smaller oplog deltas:
```javascript
db.coll.updateOne({ _id: X }, [{ $replaceWith: { $literal: entireNewDocument } }])
```
**Why:** `replaceOne` writes the full document to the oplog. The aggregation update syntax lets MongoDB compute deltas, resulting in smaller oplog entries when only a few fields are changed.
## findOneAndUpdate Misuse vs. updateOne
**Bad** — Using `findOneAndUpdate` when you don't need the document returned:
```javascript
db.coll.findOneAndUpdate(
{ _id: X },
{ $set: { status: "processed" } }
)
```
**Good** — Use `updateOne` when you don't need the result document:
```javascript
db.coll.updateOne(
{ _id: X },
{ $set: { status: "processed" } }
)
```
**Why:** `findOneAndUpdate` writes a copy of the pre-change document to a side collection for retryable writes. This overhead is unnecessary if you don't need the returned document.Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 468k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |