<!-- llms-explorer concept facts · https://llms-explorer.com/tree/hint-in-aggregate-and-update-delete/ · pack 2026-10-21 · ~1010 tokens -->

# hint in aggregate and update/delete

> Source-anchored research for hint in aggregate and update/delete. Run status: COMPLETED.

Parent: [MongoDB Explain Plans, Query Planner and Plan Cache](https://llms-explorer.com/tree/mongodb-explain-plans-query-planner-and-plan-cache/) · 4 facets · 10 facts · page: https://llms-explorer.com/tree/hint-in-aggregate-and-update-delete/

## Structure and components

- MongoDB 8.0 query-settings documentation says matching cluster query settings take precedence over command-level index hints for a query shape; the server can ignore a command's `hint` when matching query settings contain index hints. (high confidence) (verified as of 2026-10-21) — [source](https://www.mongodb.com/docs/v8.0/reference/command/setquerysettings/)

## How it works

- The C Driver's unacknowledged-write guidance lists server hint support as MongoDB 4.2+ for update commands and 4.4+ for delete commands, and says the driver should allow the option only when the server supports it. (medium confidence) (verified as of 2023-10-28) — [source](https://jira.mongodb.org/browse/CDRIVER-4127)

## Problems, failure modes and limitations

- The mongosh updateOne(), updateMany(), deleteOne(), and deleteMany() helpers accept hint to select an index for the operation's query predicate; the option accepts an index name or key pattern, and a nonexistent index makes the operation error. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/method/db.collection.updateOne.md)
- For unacknowledged OP_MSG writes, CDRIVER-4127 records a driver-spec change to allow `hint` when the server supports it: MongoDB 4.2 and later for update commands, and 4.4 and later for delete and findAndModify. For older server versions, the driver should raise a client-side error because an unacknowledged write cannot return the server's unsupported-option error. (medium confidence) — [source](https://jira.mongodb.org/browse/CDRIVER-4127)

## Facts and statements

- The aggregate command accepts hint as an index name or key-pattern document and applies it to the initial collection or view; it does not select indexes for $lookup or $graphLookup stages. (high confidence) (verified as of 2026-10-14) — [source](https://www.mongodb.com/docs/manual/reference/command/aggregate.md)
- Driver APIs expose hints differently: PyMongo bulk DeleteOne accepts an optional hint as a string or index-key input, while Mongoose's Query API lists hint under find-only setOptions() options and also exposes Query.prototype.hint(); that page does not clarify whether write methods forward it. (medium confidence) (verified as of 2026-10-21) — [source](https://github.com/mongodb/mongo-python-driver/blob/main/pymongo/operations.py)
- The aggregate command accepts `hint` as an index name or key-pattern document for the initial collection or view. It does not apply to `$lookup` or `$graphLookup`; Percona's MongoDB 3.6 coverage identifies aggregation `$hint` as a 3.6 feature. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/command/aggregate/)
- `db.collection.updateOne()` and `updateMany()` accept `hint` as an index name or key-pattern document to support the query predicate. If the requested index does not exist, the operation errors. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/db.collection.updateOne/)
- `db.collection.deleteOne()` and `deleteMany()` accept `hint` as an index name or key-pattern document to support the query predicate. If the requested index does not exist, the operation errors. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/db.collection.deleteOne/)
- Mongoose exposes `Aggregate.prototype.hint(value)` for aggregation queries; the wrapper accepts an index name or hint object. The server command documentation defines the underlying index-name and key-pattern forms. (medium confidence) (verified as of 2026-10-21) — [source](https://mongoosejs.com/docs/api/aggregate.html)
