<!-- llms-explorer concept facts · https://llms-explorer.com/tree/setquerysettings-index-hints-and-queryframework/ · pack 2026-10-31 · ~971 tokens -->

# setQuerySettings index hints and queryFramework

> Source-anchored research for setQuerySettings index hints and queryFramework. Run status: COMPLETED.

Parent: [Operation rejection filters](https://llms-explorer.com/tree/operation-rejection-filters/) · 4 facets · 12 facts · page: https://llms-explorer.com/tree/setquerysettings-index-hints-and-queryframework/

## How it works

- Tencent recommends restricting index pinning to critical queries because excessive pinning limits adaptation to changing data distributions; test representative parameter values before applying a policy. (low confidence) — [source](https://cloud.tencent.com/document/product/240/133522)

## Problems, failure modes and limitations

- Index hints restrict candidate indexes but do not guarantee index use: a collection scan can still win. An allow-list alone therefore cannot establish that a shape avoids collection scans. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- Inspect winningPlan.slotBasedPlan in explain output or queryFramework in slow-operation logs to identify the executed engine. (low confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/sbe/)

## Comparisons and alternatives

- queryFramework accepts classic or sbe. MongoDB determines SBE eligibility per query and uses classic for ineligible queries; verify the executed engine rather than assuming universal SBE support. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)

## Facts and statements

- Introduced in MongoDB 8.0, setQuerySettings applies shape-based policies to find, distinct, and aggregate across a cluster; settings survive restarts. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- Supply a representative command with $db, or an existing query shape hash string, as setQuerySettings; put the policy in the separate settings document. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- indexHints entries identify a namespace through ns.db and ns.coll; allowedIndexes accepts index names, key patterns, or $natural hints. A single entry may omit the array brackets. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- Matching query settings with index hints override command-level index hints; changing a command hint does not change its query shape. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- reject: true rejects new matching queries but leaves running operations unaffected. Index hints and queryFramework appear alongside reject in the same settings document. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- Inspect applied policies with $querySettings and the querySettings information in explain output, including per-shard entries where shown, then inspect the winning plan to confirm the selected access path. (medium confidence) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)
- Percona ClusterSync documentation dated 2026-10-13 says it does not automatically migrate persistent query settings. Export them with $querySettings and apply them separately on the destination. (low confidence) (verified as of 2026-10-31) — [source](https://docs.percona.com/percona-clustersync-for-mongodb/pqs.html)
- SERVER-89299 records a historical bug where repeating setQuerySettings for a $setWindowFields pipeline produced different queryShapeHash values and multiple configurations. The issue lists 8.0.0-rc3 among its fixes; it is not evidence of a current unfixed 8.0 defect. (low confidence) (verified as of 2026-10-31) — [source](https://jira.mongodb.org/browse/SERVER-89299)
