-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query Optimization
-
Quint 9 09/18/15, QO 2024-02-19
-
(copied to CRM)
Currently, indexed .remove() plans will always fetch the documents associated with the index keys before performing the remove:
> t.drop() true > t.ensureIndex({x: 1}) { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > t.explain().remove({x: {$gte: 5, $lte: 10}}) { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.t", "indexFilterSet" : false, "parsedQuery" : { "$and" : [ { "x" : { "$lte" : 10 } }, { "x" : { "$gte" : 5 } } ] }, "winningPlan" : { "stage" : "DELETE", "inputStage" : { "stage" : "FETCH", // This stage is not needed! "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "x" : 1 }, "indexName" : "x_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "x" : [ "[5.0, 10.0]" ] } } } }, "rejectedPlans" : [ ] }, "serverInfo" : { "host" : "dstorch-desktop", "port" : 27017, "version" : "3.1.0-pre-", "gitVersion" : "ee4db2a36eb894e2694fea781ab70f0cca33d0b8" }, "ok" : 1 }
As an optimization, we could change the query planner to generate indexed .remove() plans without the FETCH stage.
- depends on
-
SERVER-87091 Avoid the need for fetching full document when deleting by recordID
- Backlog
- is duplicated by
-
SERVER-27622 Skip document read from disk when delete with IdHack plan
- Closed
-
SERVER-86333 Avoid unnecessary fetch stage in findAndModify commands representing removals
- Closed
- related to
-
SERVER-27822 Count plans sometimes don't need a FETCH
- Closed
-
SERVER-17266 count command performance optimization should support more complex queries
- Backlog
-
SERVER-80423 Make the preImage document always available to OplogDeleteEntryArgs
- Closed