<!-- llms-explorer concept facts · https://llms-explorer.com/tree/index-filters-and-query-settings-versus-hidden-indexes/ · pack 2026-10-31 · ~1280 tokens -->

# Index filters and query settings versus hidden indexes

> Source-anchored research for Index filters and query settings versus hidden indexes. Run status: COMPLETED.

Parent: [Hidden indexes and safe index removal](https://llms-explorer.com/tree/hidden-indexes-and-safe-index-removal/) · 5 facets · 14 facts · page: https://llms-explorer.com/tree/index-filters-and-query-settings-versus-hidden-indexes/

## Structure and components

- Matching cluster query settings that contain index hints take precedence over command-level index hints. MongoDB ignores a command hint in that case, so a hint-based test must first account for the stored query settings. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setquerysettings/)

## How it works

- Legacy index filters last only for the server process and disappear after shutdown. Query settings persist across restarts and govern matching query shapes across the cluster. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/query-plans/)
- When a legacy index filter matches a query shape, MongoDB ignores the application hint(). The indexFilterSet field in explain output reveals whether a filter was applied. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/query-plans/)
- Query settings apply to executions of a query shape across the cluster and persist across restarts. Legacy index filters last only for the server process and are not readily applied to every cluster node. Percona also documents persistent query settings in its own 8.0.4-1 release. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setquerysettings/)
- For legacy filters, inspect explain output indexFilterSet. For query settings, inspect the explain querySettings document and list configured settings with the $querySettings aggregation stage; remove settings with removeQuerySettings when retiring an obsolete restriction. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/query-plans/)

## Problems, failure modes and limitations

- A hidden index cannot be used by an active legacy index filter. Directly hinting a hidden index returns an error, so hint() cannot provide a private test path to the hidden index. (high confidence) — [source](https://jira.mongodb.org/browse/DRIVERS-816)
- Without an overriding index filter or matching cluster index hints, an explicit cursor.hint() naming a hidden index returns an error. Audit application hints before a hide trial because the trial can cause query failures, not just slower execution. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/cursor.hint.md)

## Comparisons and alternatives

- MongoDB introduced setQuerySettings in 8.0 and deprecated index filters starting in 8.0. Its documented replacement is query settings, rather than using hidden indexes as per-shape planner controls. (high confidence) (verified as of 2026-10-30) — [source](https://www.mongodb.com/docs/manual/reference/command/setquerysettings/)
- Index filters and query-setting index hints restrict candidates but do not guarantee an index scan: the planner can choose a collection scan. Validate the winning plan instead of treating an allowed-index list as proof of index usage. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/query-plans/)

## Facts and statements

- Hiding an index removes it from query-planner consideration for queries on that collection. Index filters and query settings instead restrict candidate indexes for matching query shapes; these controls therefore have different scopes. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-hidden.md)
- If a legacy filter permits only an index that is hidden or absent, the planner can fall back to a collection scan. Alibaba Cloud warns that this can produce CPU and I/O spikes; check the filter and index catalog during a hide trial. (high confidence) — [source](https://help.aliyun.com/en/mongodb/use-cases/query-plans-and-query-replanning)
- A hide trial evaluates the read-plan effect of making an index unavailable while retaining the maintained index for quick unhiding. It does not reclaim the index storage or remove its write-maintenance cost, so neither hiding nor a per-shape allow-list demonstrates the write savings from dropping an index. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/index-hidden.md)
- For a removal trial, inventory legacy filters, cluster query settings, and application hints before hiding; then inspect explain output and workload behavior. This is a methodological inference from their different scopes and precedence rules. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/query-plans/)
- Query settings indexHints.allowedIndexes accepts index names, key patterns, and $natural hints. These settings restrict available candidates but do not guarantee an index scan; a collection scan can still win. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setquerysettings/)
