hint in aggregate and update/delete
Parent: MongoDB Explain Plans, Query Planner and Plan Cache · Published reference · snapshot 2026-10-21 · skill ranked-8f7c06b1
↓ Facts as markdownall context files
Source-anchored research for hint in aggregate and update/delete. 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.
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]
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]
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]
- 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]
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]
- 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]
- 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]
- `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]
- `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]
- 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]
Children
- No children recorded.