> c.find( ... { ... $or: [ ... {'_id': {$lt: lastId}, "l":{"$in": systems}, 's': { $lte: date },'e': { $gte: date }}, ... {'_id': {$lt: lastId}, "l":{"$in": systems}, 's': { $lte: date },'e': { $exists: false }} ... ] ... }, ... {'deal': 1,'transactionID': 1,'sme': 1,'marginAgreementSetId': 1,'securityAgreement': 1,'oisDiscountIndexes': 1,'l': 1,'tradeStatus': 1,'tradeDate': 1,'s': 1,'e': 1}).sort({'_id': -1}).limit(100000).explain(true) { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.CS33318", "indexFilterSet" : false, "parsedQuery" : { "$or" : [ { "$and" : [ { "s" : { "$lte" : ISODate("2010-08-22T00:00:00Z") } }, { "_id" : { "$lt" : 5000000 } }, { "e" : { "$gte" : ISODate("2010-08-22T00:00:00Z") } }, { "l" : { "$in" : [ 1, 10, 50, 100, 200, 250, 500, 600, 700, 750, 800, 900, 950, 999 ] } } ] }, { "$and" : [ { "s" : { "$lte" : ISODate("2010-08-22T00:00:00Z") } }, { "_id" : { "$lt" : 5000000 } }, { "l" : { "$in" : [ 1, 10, 50, 100, 200, 250, 500, 600, 700, 750, 800, 900, 950, 999 ] } }, { "$not" : { "e" : { "$exists" : true } } } ] } ] }, "winningPlan" : { "stage" : "SUBPLAN", "inputStage" : { "stage" : "PROJECTION", "transformBy" : { "deal" : 1, "transactionID" : 1, "sme" : 1, "marginAgreementSetId" : 1, "securityAgreement" : 1, "oisDiscountIndexes" : 1, "l" : 1, "tradeStatus" : 1, "tradeDate" : 1, "s" : 1, "e" : 1 }, "inputStage" : { "stage" : "SORT", "sortPattern" : { "_id" : -1 }, "limitAmount" : 100000, "inputStage" : { "stage" : "SORT_KEY_GENERATOR", "inputStage" : { "stage" : "FETCH", "inputStage" : { "stage" : "OR", "inputStages" : [ { "stage" : "IXSCAN", "keyPattern" : { "l" : 1, "_id" : -1, "s" : 1, "e" : 1 }, "indexName" : "l_1__id_-1_s_1_e_1", "isMultiKey" : false, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 1, "direction" : "forward", "indexBounds" : { "l" : [ "[1.0, 1.0]", "[10.0, 10.0]", "[50.0, 50.0]", "[100.0, 100.0]", "[200.0, 200.0]", "[250.0, 250.0]", "[500.0, 500.0]", "[600.0, 600.0]", "[700.0, 700.0]", "[750.0, 750.0]", "[800.0, 800.0]", "[900.0, 900.0]", "[950.0, 950.0]", "[999.0, 999.0]" ], "_id" : [ "(5000000.0, -inf.0]" ], "s" : [ "(true, new Date(1282435200000)]" ], "e" : [ "[new Date(1282435200000), new Date(9223372036854775807)]" ] } }, { "stage" : "FETCH", "filter" : { "$not" : { "e" : { "$exists" : true } } }, "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "l" : 1, "_id" : -1, "s" : 1, "e" : 1 }, "indexName" : "l_1__id_-1_s_1_e_1", "isMultiKey" : false, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 1, "direction" : "forward", "indexBounds" : { "l" : [ "[1.0, 1.0]", "[10.0, 10.0]", "[50.0, 50.0]", "[100.0, 100.0]", "[200.0, 200.0]", "[250.0, 250.0]", "[500.0, 500.0]", "[600.0, 600.0]", "[700.0, 700.0]", "[750.0, 750.0]", "[800.0, 800.0]", "[900.0, 900.0]", "[950.0, 950.0]", "[999.0, 999.0]" ], "_id" : [ "(5000000.0, -inf.0]" ], "s" : [ "(true, new Date(1282435200000)]" ], "e" : [ "[null, null]" ] } } } ] } } } } } }, "rejectedPlans" : [ ] }, "executionStats" : { "executionSuccess" : true, "nReturned" : 1521, "executionTimeMillis" : 118, "totalKeysExamined" : 13300, "totalDocsExamined" : 1522, "executionStages" : { "stage" : "SUBPLAN", "nReturned" : 1521, "executionTimeMillisEstimate" : 110, "works" : 14823, "advanced" : 1521, "needTime" : 13301, "needYield" : 0, "saveState" : 399, "restoreState" : 399, "isEOF" : 1, "invalidates" : 0, "inputStage" : { "stage" : "PROJECTION", "nReturned" : 1521, "executionTimeMillisEstimate" : 30, "works" : 14822, "advanced" : 1521, "needTime" : 13301, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "transformBy" : { "deal" : 1, "transactionID" : 1, "sme" : 1, "marginAgreementSetId" : 1, "securityAgreement" : 1, "oisDiscountIndexes" : 1, "l" : 1, "tradeStatus" : 1, "tradeDate" : 1, "s" : 1, "e" : 1 }, "inputStage" : { "stage" : "SORT", "nReturned" : 1521, "executionTimeMillisEstimate" : 30, "works" : 14822, "advanced" : 1521, "needTime" : 13301, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "sortPattern" : { "_id" : -1 }, "memUsage" : 77560, "memLimit" : 33554432, "limitAmount" : 100000, "inputStage" : { "stage" : "SORT_KEY_GENERATOR", "nReturned" : 0, "executionTimeMillisEstimate" : 30, "works" : 13301, "advanced" : 0, "needTime" : 11779, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "inputStage" : { "stage" : "FETCH", "nReturned" : 1521, "executionTimeMillisEstimate" : 30, "works" : 13300, "advanced" : 1521, "needTime" : 11778, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "docsExamined" : 1521, "alreadyHasObj" : 1, "inputStage" : { "stage" : "OR", "nReturned" : 1521, "executionTimeMillisEstimate" : 30, "works" : 13300, "advanced" : 1521, "needTime" : 11778, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "dupsTested" : 1521, "dupsDropped" : 0, "locsForgotten" : 0, "inputStages" : [ { "stage" : "IXSCAN", "nReturned" : 1520, "executionTimeMillisEstimate" : 20, "works" : 6650, "advanced" : 1520, "needTime" : 5129, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "keyPattern" : { "l" : 1, "_id" : -1, "s" : 1, "e" : 1 }, "indexName" : "l_1__id_-1_s_1_e_1", "isMultiKey" : false, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 1, "direction" : "forward", "indexBounds" : { "l" : [ "[1.0, 1.0]", "[10.0, 10.0]", "[50.0, 50.0]", "[100.0, 100.0]", "[200.0, 200.0]", "[250.0, 250.0]", "[500.0, 500.0]", "[600.0, 600.0]", "[700.0, 700.0]", "[750.0, 750.0]", "[800.0, 800.0]", "[900.0, 900.0]", "[950.0, 950.0]", "[999.0, 999.0]" ], "_id" : [ "(5000000.0, -inf.0]" ], "s" : [ "(true, new Date(1282435200000)]" ], "e" : [ "[new Date(1282435200000), new Date(9223372036854775807)]" ] }, "keysExamined" : 6650, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0 }, { "stage" : "FETCH", "filter" : { "$not" : { "e" : { "$exists" : true } } }, "nReturned" : 1, "executionTimeMillisEstimate" : 10, "works" : 6650, "advanced" : 1, "needTime" : 6648, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "docsExamined" : 1, "alreadyHasObj" : 0, "inputStage" : { "stage" : "IXSCAN", "nReturned" : 1, "executionTimeMillisEstimate" : 10, "works" : 6650, "advanced" : 1, "needTime" : 6648, "needYield" : 0, "saveState" : 116, "restoreState" : 116, "isEOF" : 1, "invalidates" : 0, "keyPattern" : { "l" : 1, "_id" : -1, "s" : 1, "e" : 1 }, "indexName" : "l_1__id_-1_s_1_e_1", "isMultiKey" : false, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 1, "direction" : "forward", "indexBounds" : { "l" : [ "[1.0, 1.0]", "[10.0, 10.0]", "[50.0, 50.0]", "[100.0, 100.0]", "[200.0, 200.0]", "[250.0, 250.0]", "[500.0, 500.0]", "[600.0, 600.0]", "[700.0, 700.0]", "[750.0, 750.0]", "[800.0, 800.0]", "[900.0, 900.0]", "[950.0, 950.0]", "[999.0, 999.0]" ], "_id" : [ "(5000000.0, -inf.0]" ], "s" : [ "(true, new Date(1282435200000)]" ], "e" : [ "[null, null]" ] }, "keysExamined" : 6650, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0 } } ] } } } } } }, "allPlansExecution" : [ ] }, "serverInfo" : { "host" : "Chriss-MacBook-Pro.local", "port" : 31001, "version" : "3.2.4", "gitVersion" : "e2ee9ffcf9f5a94fad76802e28cc978718bb7a30" }, "ok" : 1 }