Skip to main content
← Back to list
01Issue
FeatureOpenSwamp Club
AssigneesNone

Optimise MongoDB Search Queries

Opened by stack72 · 4/9/2026· GitHub #148

See notification from MongoDB


We noticed that your MongoDB Search queries in your swamp-club cluster in project Swamp Production use $match after $search. Optimizing your aggregation pipeline can improve query performance by up to 10x.

Using stages like $match, $sort, or $count after a $search stage can introduce unnecessary overhead and slow down your queries—especially at scale. In most cases, similar functionality can be achieved directly within $search, resulting in faster execution, more efficient resource use, and a smoother search experience. By handling filtering, sorting, and counting within $search, you can improve both performance and accuracy.

Here's what to consider:

Move filtering logic from $match into the $search stage using the compound operator’s filter clause. If you’re using $sort after $search: Use the sort option inside $search, or the near operator for geo fields. If you’re using $count after $search: Try count inside $search or $searchMeta for better performance. To help you refactor more efficiently, check out our guide to optimizing query performance.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

4/9/2026, 4:43:00 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.