BLUENEXUS INTEGRATIONSHOW-TO

A MongoDB index review before every release, for the whole backend team

Most MongoDB slowdowns ship in a release. A new query filters on a field nobody indexed, works fine on a laptop with a thousand documents, and scans three million in production. Meanwhile, indexes from features long gone still slow down every write. Nobody meant for either to happen. Nobody looked.

A short index review before each release fixes that. The author lists the new queries, the AI explains each one against the real collection, and the team decides what to add, hide or drop. Creating and dropping indexes stays with people.

Here's who does what, three prompts, and how a delivery app reviews release 4.13.

Who does what

Who does what

The authorLists the new or changed queries in the release.
The reviewerChecks each query's plan, and approves new or dropped indexes.
On-callSchedules index builds, and watches the release.
The backend leadDecides on indexes that cost more than they save.

What to check

  • New queries. Does each one use an index, or scan the collection? Compare documents examined with documents returned.
  • Index order. Compound indexes work best in equality, sort, range order.
  • Unused indexes. Every index costs writes and storage. Hide before you drop.
  • Redundant indexes. An index that's a prefix of another is usually no longer needed.

Start with MongoDB's own tools

On Atlas, Performance Advisor suggests indexes from slow queries and flags unused and redundant ones, on M10 and larger clusters. explain shows any query's plan, and $indexStats shows how often each index is used.

What's left is doing it before the release, not after, with the people who'll own the change.

Do it in Claude or ChatGPT

Connect MongoDB with our guide to MongoDB in Claude, ChatGPT and MCP, read-only. The first two prompts only read. The third only suggests.

Explain the new queries.

1Paste this into Claude or ChatGPT

Using MongoDB, explain these queries from the release: [paste queries]. For each, say whether it uses an index or scans the collection, and how many documents it examines against how many it returns. Don't change anything.

Copy prompt

Unused and redundant indexes.

1Paste this into Claude or ChatGPT

List the indexes on [collection] with their usage from $indexStats, and flag any that look unused or are a prefix of another index. Remember the counters reset when a server restarts. Don't change anything.

Copy prompt

Design the index.

1Paste this into Claude or ChatGPT

Suggest an index for this query, following MongoDB's equality, sort, range rule: [paste query]. Say what it adds to write cost, and whether an existing index could be extended instead.

Copy prompt

A few things to know:

  • Explain against production data. A query that's fast on a test database can scan millions in production.
  • Unused isn't always safe. Counters reset on restart, and a monthly report may need an index nobody used this week.
  • Hide, then drop. A hidden index can come back in seconds. A dropped one takes a rebuild.
  • Build in a quiet window. Heavy writes slow an index build.

When the backend team ships together

On your own, you'd check your own queries. In a team, Hollis writes the feature, Sasha reviews it, Blake is on call the night it ships, and a missing index becomes everyone's problem at 2am.

Sparrowhawk, a 45-person grocery delivery app in Nashville, reviews indexes in BlueNexus. MongoDB is connected. Every Thursday at 14:00, before the next Tuesday release, the schema agent checks the new queries Hollis listed against the orders collection and its indexes, and prepares the review for Sasha.

Illustration of the BlueNexus app with example data.

Illustration of the BlueNexus app with example data.

One new query has no index and would scan three million orders. One old index served a report that's gone, and another becomes redundant once the new one exists. The agent prepares the next steps for Sasha.

Sasha approves. Hollis adds the index to the migration on Friday, and Blake schedules the build for Monday night. Sasha hides the old region index and sets a reminder to drop it in a week.

Illustration of the BlueNexus app with example data.

For connecting MongoDB, see MongoDB in Claude, ChatGPT and MCP. For schemas, see how to find schema drift in MongoDB. To review releases with your team, sign up for BlueNexus.

Questions people ask about MongoDB and AI

How do I find slow queries in MongoDB?

On Atlas, the Query Profiler and Performance Advisor show slow queries and suggest indexes on M10 and larger clusters. Anywhere, explain a query to see whether it scans the collection, and compare documents examined with documents returned.

How do I find unused indexes in MongoDB?

Use $indexStats to see how often each index is used. Counters reset on restart and are kept per server, so check across members and over a long enough period. Atlas Performance Advisor also suggests indexes to drop.

Should I drop an unused MongoDB index straight away?

Hide it first. A hidden index isn't used by queries but is kept up to date, so you can unhide it at once if something slows down. Drop it after a quiet week.

What is the ESR rule in MongoDB?

Order compound index keys by equality first, then sort, then range. It usually gives the most efficient index for a query.

Do index builds slow down MongoDB?

Builds hold an exclusive lock only briefly at the start and end, but heavy writes during a build slow it down. Many teams build large indexes in a quiet window.

Subscribe to our blog

Product insights, AI and product thinking delivered to your inbox.