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

# Query settings: index hints and queryFramework (persistent query settings)

> Source-anchored research for Query settings: index hints and queryFramework (persistent query settings). Run status: COMPLETED.

Parent: [Operation rejection filters](https://llms-explorer.com/tree/operation-rejection-filters/) · 3 facets · 15 facts · page: https://llms-explorer.com/tree/query-settings-index-hints-and-queryframework-persistent-query-settings/

## How it works

- Tencent recommends restricting persistent index choices to critical queries and reassessing them when data distribution changes; blanket pinning sacrifices adaptive index selection. (low confidence) — [source](https://cloud.tencent.com/document/product/240/133522)
- Tencent recommends limiting persistent index restrictions to critical queries, checking the applied querySettings and winningPlan with explain, and reconsidering restrictions when workload or data distribution changes. (low confidence) (verified as of 2026-10-31) — [source](https://cloud.tencent.com/document/product/240/133522)

## Problems, failure modes and limitations

- Inspect applied settings with $querySettings and explain. Check winningPlan.slotBasedPlan or the slow-log queryFramework field to identify the execution engine actually used. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- SERVER-88948 documents a historical min/max-query failure: query settings suppressed cursor hints, but the resulting error bypassed the NoQueryExecutionPlans fallback. It lists fixes in 8.0.0-rc2 and 8.1.0-rc0. (low confidence) (verified as of 2026-09-21) — [source](https://jira.mongodb.org/browse/SERVER-88948)
- queryFramework accepts classic or sbe. SBE eligibility remains query- and version-dependent; MongoDB uses classic for ineligible queries. Check slotBasedPlan in explain or queryFramework in slow logs to identify the actual engine. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)

## Facts and statements

- MongoDB 8.0 introduced persistent query settings: setQuerySettings applies to matching find, distinct, and aggregate query shapes across the cluster, and settings survive restarts. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- setQuerySettings accepts a representative command with $db or a query-shape hash string. indexHints specifies ns.db, ns.coll, and allowedIndexes containing index names, key patterns, or $natural hints. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- allowedIndexes restricts planner choices; it does not guarantee an index scan. A collection scan can still win. (low confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- Matching persistent indexHints take precedence over command-level index hints, so an application hint may not control the effective plan. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- queryFramework accepts classic or sbe to select an execution engine for a query shape. SBE eligibility still depends on the query's supported operators and expressions. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- Percona ClusterSync documentation says it does not automatically migrate persistent query settings. Export them with $querySettings and apply them on the destination using setQuerySettings. (low confidence) (verified as of 2026-10-13) — [source](https://docs.percona.com/percona-clustersync-for-mongodb/pqs.html)
- In the cached MongoDB 9.0 documentation, distinct's command-level querySettings applies only to one execution; persistent cluster settings override conflicting fields. (medium confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/command/distinct.md)
- Persistent indexHints restrict available indexes but do not guarantee index use; the planner can still choose a collection scan. Matching persistent index hints take precedence over command-level hints. (low confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/command/setQuerySettings.md)
- Inspect settings with db.aggregate([{ $querySettings: {} }]); remove them with removeQuerySettings using a representative query or queryShapeHash. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/querySettings.md)
- Percona ClusterSync does not automatically migrate persistent query settings. Its documented procedure exports them with $querySettings and reapplies them on the destination after replication is finalized; both clusters must run MongoDB 8.0 or later. (low confidence) (verified as of 2026-10-13) — [source](https://docs.percona.com/percona-clustersync-for-mongodb/pqs.html)
