<!-- llms-explorer concept facts · https://llms-explorer.com/tree/per-node-and-per-shard-indexstats-aggregation-across-replica-sets-and-shards/ · pack 2026-10-30 · ~1317 tokens -->

# Per-node and per-shard $indexStats aggregation across replica sets and shards

> Source-anchored research for Per-node and per-shard $indexStats aggregation across replica sets and shards. Run status: COMPLETED.

Parent: [Unused index detection with $indexStats](https://llms-explorer.com/tree/unused-index-detection-with-indexstats/) · 6 facets · 14 facts · page: https://llms-explorer.com/tree/per-node-and-per-shard-indexstats-aggregation-across-replica-sets-and-shards/

## Definitions

- A zero count is a candidate-review signal, not sufficient grounds for dropping an index. Review all members and workloads that run infrequently; a short observation window can miss necessary usage. (high confidence) — [source](https://docs.percona.com/percona-monitoring-and-management/3/advisors/checks/mongodb-unused-indexes.html)

## How it works

- Results identify the mongod host and, for sharded deployments, the shard. Keep both identities when collecting per-index measurements. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Index counters reset on mongod restart, index drop/recreation, or modification with collMod. Preserve accesses.since when comparing samples; raw cumulative counts from different observation windows are not directly comparable. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Methodological inference: collect per-host samples before grouping by shard and index; compare intervals only when counter epochs match. A shard rollup otherwise hides unsampled members or differing observation windows. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)

## How-to and procedures

- Run db.collection.aggregate([{ $indexStats: {} }]). The stage must come first and takes an empty document. Rows include index name and key, originating host, accesses.ops and accesses.since; sharded output also identifies the shard. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)

## Problems, failure modes and limitations

- Studio 3T demonstrates separate purposes: explain displays a particular query’s index use and document retrieval, whereas $indexStats reports usage frequency. Usage counts alone cannot establish query coverage. (low confidence) — [source](https://studio3t.com/whats-new/are-my-mongodb-indexes-being-used-studio3t_ama/)
- An OpenTelemetry receiver issue reported direct shard-member monitoring still issuing IndexStats despite disabled database metrics, using Splunk Collector 0.127.0. This is a version-specific monitoring caveat, not proof of current behavior. (low confidence) (verified as of 2026-02-06) — [source](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/45924)

## Comparisons and alternatives

- Percona PMM documents that its unused-index advisor requires the indexStats metric collector. Missing advisor evidence can therefore reflect collection configuration rather than an absence of index usage. (low confidence) — [source](https://docs.percona.com/percona-monitoring-and-management/3/advisors/checks/mongodb-unused-indexes.html)

## Facts and statements

- $indexStats accesses counters are local to the node executing the query. Usage on a secondary is not recorded on the primary or other members; inspect every relevant replica-set member before declaring an index unused. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- MongoDB issue SERVER-96438, updated October 12, 2026 and recorded as unresolved, describes mongos collecting results across shard primaries while omitting secondaries. Its request for all-node results is proposed behavior, not evidence that the feature exists. (low confidence) (verified as of 2026-10-12) — [source](https://jira.mongodb.org/browse/SERVER-96438)
- accesses.ops counts user operations using an index; TTL deletions and chunk split or migration activity are excluded. It is not a count of indexed documents. (low confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Methodological inference: retain collection namespace, index specification, shard and host before rolling up counters. Collect nodes explicitly; summing mongos-returned rows alone must not be presented as all-member coverage. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Methodological inference for covered-query analysis: index-use counters alone do not establish query coverage. Pair them with explain executionStats to inspect the actual index and document-scanning behavior of the specific query. (medium confidence) — [source](https://www.mongodb.com/docs/manual/tutorial/measure-index-use.md)
- Historical counterexample: a MongoDB 3.2.11 incident report describes worse performance after dropping zero-counter indexes. The issue was closed as a duplicate of a checkpoint-related drop issue; it does not establish that current indexStats counters are defective. (low confidence) — [source](https://jira.mongodb.org/browse/SERVER-29419)
