<!-- llms-explorer concept facts · https://llms-explorer.com/tree/indexstats-usage-statistics-and-their-reset-conditions/ · pack 2026-10-31 · ~999 tokens -->

# $indexStats usage statistics and their reset conditions

> Source-anchored research for $indexStats usage statistics and their reset conditions. Run status: COMPLETED.

Parent: [Hidden indexes and safe index removal](https://llms-explorer.com/tree/hidden-indexes-and-safe-index-removal/) · 4 facets · 14 facts · page: https://llms-explorer.com/tree/indexstats-usage-statistics-and-their-reset-conditions/

## How it works

- Observe a representative application cycle before removing a zero-use index; infrequent reporting queries can depend on it. (medium confidence) — [source](https://www.percona.com/blog/identifying-unused-indexes-in-mongodb/)
- Store usage metrics externally when history must survive restarts. Treat any counter reset as a new observation window when comparing samples. (medium confidence) — [source](https://www.percona.com/blog/identifying-unused-indexes-in-mongodb/)

## How-to and procedures

- Run db.collection.aggregate([{ $indexStats: {} }]) for per-index usage documents; $indexStats must be the pipeline's first stage. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)

## Comparisons and alternatives

- accesses.ops counts user operations that used the index; accesses.since marks when MongoDB began collecting those statistics, rather than the last access time. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)

## Facts and statements

- A mongod restart resets index statistics; dropping and recreating an index also starts a new statistics window. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Modifying an existing index through collMod resets that index's statistics; changing its hidden state is a documented example. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Hiding a visible index and unhiding a hidden index each reset its $indexStats counters. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-hidden.md)
- Hiding an already hidden index or unhiding an already visible index does not reset its statistics. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/index-hidden.md)
- Usage statistics describe the queried node. Check all relevant replica-set members, including secondaries serving reads, before declaring an index unused. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- Internal TTL deletion, chunk split, and migration operations do not increment the reported usage counters. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- A zero ops value does not establish that an index is unnecessary: uniqueness enforcement on insertion does not increment this counter. (low confidence) — [source](https://www.percona.com/blog/identifying-unused-indexes-in-mongodb/)
- For interval monitoring, subtract two index-operation samples only while the node, index identity and statistics-start epoch remain comparable; reject intervals spanning a reset. This is a methodological inference from the documented resets. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md)
- For a particular query, inspect explain output to establish its execution plan. $indexStats supplies aggregate usage frequency, so its counter alone does not establish that the query used SORT_MERGE. (medium confidence) — [source](https://studio3t.com/whats-new/are-my-mongodb-indexes-being-used-studio3t_ama/)
- Changing an index from visible to hidden, or hidden to visible, resets its $indexStats. Hiding an already hidden index or unhiding an already visible index does not reset them. (low confidence) — [source](https://www.mongodb.com/docs/manual/core/index-hidden.md)
