<!-- llms-explorer concept facts · https://llms-explorer.com/tree/tracked-query-memory-across-explain-currentop-and-profiler/ · pack 2026-10-29 · ~1279 tokens -->

# Tracked query memory across explain, currentOp and profiler

> Source-anchored research for Tracked query memory across explain, currentOp and profiler. Run status: COMPLETED.

Parent: [MongoDB Monitoring and Observability](https://llms-explorer.com/tree/mongodb-monitoring-and-observability/) · 4 facets · 12 facts · page: https://llms-explorer.com/tree/tracked-query-memory-across-explain-currentop-and-profiler/

## How it works

- The inspected master implementation of CurOp::setMemoryTrackingStats raises its stored peak only when a larger value arrives, then updates current in-use bytes. It writes peak first to maintain peak >= in-use. This is implementation evidence, not verification of every release branch. (low confidence) (verified as of 2026-10-27) — [source](https://github.com/mongodb/mongo/blob/master/src/mongo/db/curop.cpp)

## Problems, failure modes and limitations

- MongoDB 8.3 introduces inUseTrackedMemBytes and peakTrackedMemBytes in profiler output. They describe current tracked bytes and maximum tracked bytes, respectively. Release coverage also places query-memory tracking in currentOp and slow-query logs. (high confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/manual/reference/database-profiler/)
- MongoDB recommends the $currentOp aggregation stage over the deprecated currentOp command and db.currentOp() method; run the stage first in a pipeline on the admin database. On mongos, localOps:true inspects the router, while false inspects shard operations. (low confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/v8.3/reference/operator/aggregation/currentop/)
- Zero tracked bytes cannot establish zero memory consumption: SERVER-133136 describes specific internal DBDirectClient bucket-reopening reads with no blocking stages, no OperationMemoryUsageTracker and zero tracked bytes. This is a scoped implementation observation; the issue lists no affected or fix versions. (low confidence) (verified as of 2026-08-10) — [source](https://jira.mongodb.org/browse/SERVER-133136)

## Comparisons and alternatives

- The profiler fields system.profile.inUseTrackedMemBytes and system.profile.peakTrackedMemBytes have the same current-versus-maximum definitions as the live $currentOp fields, enabling comparison of those measurements across the two diagnostic surfaces. (medium confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/manual/reference/database-profiler/)

## Facts and statements

- MongoDB 8.3 explain.executionStats.peakTrackedMemBytes reports the whole-query tracked-memory peak and explain also reports blocking-stage peaks. With one blocking stage, the documented query and stage peaks are equal. (low confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/v8.3/reference/explain-results/)
- A diagnostic workflow can compare live currentOp memory with captured profiler memory, then use executionStats explain to locate blocking-stage peaks. This is a synthesis of documented surfaces, not evidence of an automatic correlation service or identical replay. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/database-profiler/)
- Treat explain as a separate experiment: it ignores the plan cache and does not cache its winning plan. planCacheShapeHash groups plan-cache query shapes; matching hashes do not prove two observations belong to one execution. (medium confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/v8.3/reference/explain-results/)
- SERVER-104648 separately adds memory statistics to QueryStats. It is marked Fixed with fix version 9.0.0-rc0 and requests peakTrackedMemBytes aggregation across shards and mongos. The 8.3 profiler/explain feature alone does not establish QueryStats support in 8.3. (low confidence) (verified as of 2026-09-25) — [source](https://jira.mongodb.org/browse/SERVER-104648)
- MongoDB explicitly documents both memory fields in $currentOp, db.currentOp(), profiler output and log messages; it separately lists peakTrackedMemBytes for explain results, PlanCache.list() and $planCacheStats. (medium confidence) (verified as of 2026-10-27) — [source](https://www.mongodb.com/docs/v8.3/release-notes/8.3/)
- Percona's July 30, 2026 announcement lists query memory tracking among the observability features of its own Percona Server for MongoDB 8.3 Technical Preview. The announcement's preview status is historical, not a claim about its current production status. (low confidence) (verified as of 2026-07-30) — [source](https://www.percona.com/blog/percona-server-for-mongodb-8-3-technical-preview-is-now-available/)
- Alibaba's ApsaraDB for MongoDB 8.3 documentation lists per-operation memory tracking and describes inUseTrackedMemBytes as current memory and peakTrackedMemBytes as peak memory. Its broad field-placement summary should be scoped using MongoDB's more explicit surface-by-surface documentation. (medium confidence) (verified as of 2026-09-10) — [source](https://www.alibabacloud.com/help/en/mongodb/product-overview/features-of-mongodb-8-3)
