$indexStats usage statistics and their reset conditions
Parent: Hidden indexes and safe index removal · Published reference · snapshot 2026-10-31
↓ Facts as markdownall context files
Source-anchored research for $indexStats usage statistics and their reset conditions. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
How it works
- Observe a representative application cycle before removing a zero-use index; infrequent reporting queries can depend on it. (medium confidence) [source]
- Store usage metrics externally when history must survive restarts. Treat any counter reset as a new observation window when comparing samples. (medium confidence) [source]
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]
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]
Facts and statements
- A mongod restart resets index statistics; dropping and recreating an index also starts a new statistics window. (medium confidence) [source]
- Modifying an existing index through collMod resets that index's statistics; changing its hidden state is a documented example. (high confidence) [source]
- Hiding a visible index and unhiding a hidden index each reset its $indexStats counters. (high confidence) [source]
- Hiding an already hidden index or unhiding an already visible index does not reset its statistics. (medium confidence) [source]
- Usage statistics describe the queried node. Check all relevant replica-set members, including secondaries serving reads, before declaring an index unused. (medium confidence) [source]
- Internal TTL deletion, chunk split, and migration operations do not increment the reported usage counters. (medium confidence) [source]
- A zero ops value does not establish that an index is unnecessary: uniqueness enforcement on insertion does not increment this counter. (low confidence) [source]
- 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]
- 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]
- 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]
Children
- Detecting counter epochs across monitoring samples (frontier)
- Business-cycle coverage for unused-index analysis (frontier)
Frontier under this node: Business-cycle coverage for unused-index analysis, Detecting counter epochs across monitoring samples