<!-- llms-explorer concept facts · https://llms-explorer.com/tree/mergecursors-stage-in-explain/ · pack 2026-10-22 · ~1330 tokens -->

# $mergeCursors stage in explain

> Source-anchored research for $mergeCursors stage in explain. Run status: COMPLETED.

Parent: [MongoDB Advanced Explain: Aggregation, Sharded Plans, Loose Index Scans and the 8.3 Cost-Based Ranker](https://llms-explorer.com/tree/mongodb-advanced-explain-aggregation-sharded-plans-loose-index-scans-and-the-8-3-cost-based-ranker/) · 4 facets · 10 facts · page: https://llms-explorer.com/tree/mergecursors-stage-in-explain/

## How it works

- As of the 2026-10-22 source snapshot, MongoDB master comments that execution statistics are not supported when explain builds mergerPart. SERVER-79805 describes the same observability gap for $mergeCursors and later merger stages, so per-shard execution statistics do not by themselves show merger-side work or router/network latency. (medium confidence) (verified as of 2026-10-22) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/pipeline/sharded_agg_helpers.cpp)

## Problems, failure modes and limitations

- As of 2026-10-22, MongoDB's current server source serializes the merger explain at `queryPlanner` verbosity because merger execution stats are unsupported, and it serializes `$mergeCursors` without actual remote cursors. The explain therefore describes merger plan structure but cannot quantify mongos-side merge work or network latency; SERVER-79805 records this gap. (high confidence) (verified as of 2026-10-22) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/pipeline/sharded_agg_helpers.cpp)

## Comparisons and alternatives

- Read sharded aggregation explain through splitPipeline, mergeType, and shards: they show the shard and merger pipeline portions, the selected merge location, and per-shard work. Aggregation explain output is optimized and can differ from the submitted pipeline; the query-plan label SHARD_MERGE is distinct from the aggregation stage $mergeCursors. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/sharded-cluster-query-router/)
- The CVE-2025-6713 release notes disagree on the MongoDB 7.0 affected-version cutoff: MongoDB's 7.0.19 prose says versions before 7.0.6 while its affected-version list ends at 7.0.18, and Percona Distribution 7.0.22 says versions before 7.0.20. Check the exact upstream or Percona build instead of relying on the prose cutoff. (high confidence) (verified as of 2025-07-28) — [source](https://www.mongodb.com/docs/manual/release-notes/7.0.md)

## Facts and statements

- As of 2026-10-22, MongoDB's current server source serializes `$mergeCursors` as the first stage in `splitPipeline.mergerPart`. MongoDB's change stream source docs say the stage aggregates responses from remote shards, and sometimes the config server, into a sorted stream. The SERVER-57383 ticket and the related TOOLS-3024 investigation document that merge sorting can happen inside `$mergeCursors`, which explains why merger output may lack a standalone `$sort`; do not infer that merged results are unsorted. (high confidence) (verified as of 2026-10-22) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/pipeline/sharded_agg_helpers.cpp)
- MongoDB's manual says `mergeType` identifies where the merge runs (`anyShard`, `specificShard`, or `router`); for `specificShard`, the output includes the merging shard identifier. The manual says `splitPipeline` shows operations assigned to shards and the merger, while `shards` reports each shard's work. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/core/sharded-cluster-query-router.md)
- DataDog's MongoDB integration changelog says releases 9.0.0 / Agent 7.65.0 and 8.6.0 / Agent 7.64.x skip explain on aggregation pipelines containing `$mergeCursors` to prevent potential MongoDB crashes. (low confidence) (verified as of 2025-03-25) — [source](https://github.com/DataDog/integrations-core/blob/master/mongo/CHANGELOG.md)
- Percona's MongoDB 7.0.22 distribution release notes report that improper `$mergeCursors` handling could permit unauthorized data access and that the release includes the upstream handling fix. (low confidence) (verified as of 2025-07-28) — [source](https://docs.percona.com/percona-distribution-for-mongodb/7.0/release-notes-v7.0.22.html)
- MongoDB's sharded aggregation helper normally prepends $mergeCursors to the merger pipeline to consume remote shard cursors. For explain, it establishes no remote cursors and instead serializes a $mergeCursors entry with arm parameters but no remotes; MongoDB Tools describes this entry as the first stage of mergerPart in sharded explain output. (high confidence) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/pipeline/sharded_agg_helpers.cpp)
- MongoDB's issue history shows that older sharded aggregation explains omitted the final merge-sort phase from mergerPart while the sorted merge still occurred. The SERVER-57383 examples show the omission in 4.2 and 4.4 output and list 5.3.0 as the fix version; an independent aggregation guide describes the affected range as 4.2 through 5.2. Do not infer unsorted results from the missing merger sort in those historical explain formats. (medium confidence) (verified as of 2025-09-26) — [source](https://jira.mongodb.org/browse/SERVER-57383)
