-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query Execution
-
Query 2017-05-29
-
(copied to CRM)
On a large collection with index on "orderdate" compare find and equivalent aggregate first batches:
command: find { find: "orders", filter: { orderdate: { $gte: new Date(759024000000) } }, sort: { orderdate: -1.0 }, projection: { _id: 0.0, orderdate: 1.0 } } planSummary: IXSCAN { orderdate: 1 } cursorid:53712819499 keysExamined:101 docsExamined:0 numYields:0 nreturned:101 reslen:2903 0ms command: aggregate { aggregate: "orders", pipeline: [ { $match: { orderdate: { $gte: new Date(759024000000) } } }, { $sort: { orderdate: -1.0 } }, { $project: { _id: 0.0, orderdate: 1.0 } } ], cursor: {} } planSummary: IXSCAN { orderdate: 1 } cursorid:52250968997 keysExamined:20972 docsExamined:0 numYields:163 nreturned:101 reslen:2903 11ms
The main performance difference seems to come from keysExamined which is 101 in case of find and equal to I'm not sure what in the second case (there are 2406 distinct orderdate values, collection size is 1500000 and this filter reduces it to 1034289 documents).
- is related to
-
SERVER-47370 Projection pushdown can hinder performance for workloads with tiny documents
- Backlog
- related to
-
SERVER-31072 reorder $limit before $lookup in pipeline
- Closed