can not get data when using db.coll.find({a:null})

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.0.7
    • Component/s: Querying
    • None
    • ALL
    • Hide
      rs0:SECONDARY> db.members.count({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      0   
      
      rs0:SECONDARY> db.members.find({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      rs0:SECONDARY> 
      
      
      rs0:SECONDARY> db.members.count({ isQuited: false, _teamId:{$exists:false}, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      76  
      
      rs0:SECONDARY> db.members.find({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }).explain("executionStats")
      {
              "queryPlanner" : {
                      "plannerVersion" : 1,
                      "namespace" : "XXX.members",
                      "indexFilterSet" : false,
                      "parsedQuery" : {
                              "$and" : [
                                      {
                                              "_boundToObjectId" : {
                                                      "$eq" : ObjectId("51762b8f78cfa9f357000011")
                                              }
                                      },
                                      {
                                              "_teamId" : {
                                                      "$eq" : null
                                              }
                                      },
                                      {
                                              "isQuited" : {
                                                      "$eq" : false
                                              }
                                      }
                              ]
                      },
                      "winningPlan" : {
                              "stage" : "FETCH",
                              "filter" : {
                                      "$and" : [
                                              {
                                                      "_teamId" : {
                                                              "$eq" : null
                                                      }
                                              },
                                              {
                                                      "isQuited" : {
                                                              "$eq" : false
                                                      }
                                              }
                                      ]
                              },
                              "inputStage" : {
                                      "stage" : "IXSCAN",
                                      "keyPattern" : {
                                              "_boundToObjectId" : 1
                                      },
                                      "indexName" : "_boundToObjectId_1",
                                      "isMultiKey" : false,
                                      "direction" : "forward",
                                      "indexBounds" : {
                                              "_boundToObjectId" : [
                                                      "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]"
                                              ]
                                      }
                              }
                      },
                      "rejectedPlans" : [ ]
              },
              "executionStats" : {
                      "executionSuccess" : true,
                      "nReturned" : 76,
                      "executionTimeMillis" : 8,
                      "totalKeysExamined" : 92,
                      "totalDocsExamined" : 92,
                      "executionStages" : {
                              "stage" : "FETCH",
                              "filter" : {
                                      "$and" : [
                                              {
                                                      "_teamId" : {
                                                              "$eq" : null
                                                      }
                                              },
                                              {
                                                      "isQuited" : {
                                                              "$eq" : false
                                                      }
                                              }
                                      ]
                              },
                              "nReturned" : 76,
                              "executionTimeMillisEstimate" : 0,
                              "works" : 93,
                              "advanced" : 76,
                              "needTime" : 16,
                              "needFetch" : 0,
                              "saveState" : 0,
                              "restoreState" : 0,
                              "isEOF" : 1,
                              "invalidates" : 0,
                              "docsExamined" : 92,
                              "alreadyHasObj" : 0,
                              "inputStage" : {
                                      "stage" : "IXSCAN",
                                      "nReturned" : 92,
                                      "executionTimeMillisEstimate" : 0,
                                      "works" : 93,
                                      "advanced" : 92,
                                      "needTime" : 0,
                                      "needFetch" : 0,
                                      "saveState" : 0,
                                      "restoreState" : 0,
                                      "isEOF" : 1,
                                      "invalidates" : 0,
                                      "keyPattern" : {
                                              "_boundToObjectId" : 1
                                      },
                                      "indexName" : "_boundToObjectId_1",
                                      "isMultiKey" : false,
                                      "direction" : "forward",
                                      "indexBounds" : {
                                              "_boundToObjectId" : [
                                                      "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]"
                                              ]
                                      },
                                      "keysExamined" : 92,
                                      "dupsTested" : 0,
                                      "dupsDropped" : 0,
                                      "seenInvalidated" : 0,
                                      "matchTested" : 0
                              }
                      }
              },
              "serverInfo" : {
                      "host" : "xxxxxxxxxx",
                      "port" : 27017,
                      "version" : "3.0.7",
                      "gitVersion" : "6ce7cbe8c6b899552dadd907604559806aa2e9bd"
              },
              "ok" : 1
      }                                                          
      
      rs0:SECONDARY> db.members.getPlanCache().getPlansByQuery({isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      [
              {
                      "details" : {
                              "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf { _teamId: 1.0 }, pos: 0\n---Leaf \n)"
                      },
                      "reason" : {
                              "score" : 1.5003000000000002,
                              "stats" : {
                                      "stage" : "LIMIT",
                                      "nReturned" : 1,
                                      "executionTimeMillisEstimate" : 0,
                                      "works" : 2,
                                      "advanced" : 1,
                                      "needTime" : 1,
                                      "needFetch" : 0,
                                      "saveState" : 0,
                                      "restoreState" : 0,
                                      "isEOF" : 1,
                                      "invalidates" : 0,
                                      "limitAmount" : 0,
                                      "inputStage" : {
                                              "stage" : "FETCH",
                                              "filter" : {
                                                      "$and" : [
                                                              {
                                                                      "_boundToObjectId" : {
                                                                              "$eq" : ObjectId("572866b38b35ba316d9d41af")
                                                                      }
                                                              },
                                                              {
                                                                      "isQuited" : {
                                                                              "$eq" : false
                                                                      }
                                                              }
                                                      ]
                                              },
                                              "nReturned" : 1,
                                              "executionTimeMillisEstimate" : 0,
                                              "works" : 2,
                                              "advanced" : 1,
                                              "needTime" : 1,
                                              "needFetch" : 0,
                                              "saveState" : 0,
                                              "restoreState" : 0,
                                              "isEOF" : 0,
                                              "invalidates" : 0,
                                              "docsExamined" : 2,
                                              "alreadyHasObj" : 0,
                                              "inputStage" : {
                                                      "stage" : "IXSCAN",
                                                      "nReturned" : 2,
                                                      "executionTimeMillisEstimate" : 0,
                                                      "works" : 2,
                                                      "advanced" : 2,
                                                      "needTime" : 0,
                                                      "needFetch" : 0,
                                                      "saveState" : 0,
                                                      "restoreState" : 0,
                                                      "isEOF" : 0,
                                                      "invalidates" : 0,
                                                      "keyPattern" : {
                                                              "_teamId" : 1
                                                      },
                                                      "indexName" : "_teamId_1",
                                                      "isMultiKey" : false,
                                                      "direction" : "forward",
                                                      "indexBounds" : {
                                                              "_teamId" : [
                                                                      "[ObjectId('56fb4e0fc6ec2b612e7e6214'), ObjectId('56fb4e0fc6ec2b612e7e6214')]"
                                                              ]
                                                      },
                                                      "keysExamined" : 2,
                                                      "dupsTested" : 0,
                                                      "dupsDropped" : 0,
                                                      "seenInvalidated" : 0,
                                                      "matchTested" : 0
                                              }
                                      }
                              }
                      },
                      "feedback" : {
                              "nfeedback" : 20,
                              "averageScore" : NaN,
                              "stdDevScore" : NaN,
                              "scores" : [
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      },
                                      {
                                              "score" : NaN
                                      }
                              ]
                      },
                      "filterSet" : false
              },
              {
                      "details" : {
                              "solution" : "(index-tagged expression tree: tree=Node\n---Leaf { _boundToObjectId: 1.0 }, pos: 0\n---Leaf \n---Leaf \n)"
                      },
                      "reason" : {
                              "score" : 1.0003,
                              "stats" : {
                                      "stage" : "LIMIT",
                                      "nReturned" : 0,
                                      "executionTimeMillisEstimate" : 0,
                                      "works" : 2,
                                      "advanced" : 0,
                                      "needTime" : 2,
                                      "needFetch" : 0,
                                      "saveState" : 0,
                                      "restoreState" : 0,
                                      "isEOF" : 0,
                                      "invalidates" : 0,
                                      "limitAmount" : 1,
                                      "inputStage" : {
                                              "stage" : "FETCH",
                                              "filter" : {
                                                      "$and" : [
                                                              {
                                                                      "_teamId" : {
                                                                              "$eq" : ObjectId("56fb4e0fc6ec2b612e7e6214")
                                                                      }
                                                              },
                                                              {
                                                                      "isQuited" : {
                                                                              "$eq" : false
                                                                      }
                                                              }
                                                      ]
                                              },
                                              "nReturned" : 0,
                                              "executionTimeMillisEstimate" : 0,
                                              "works" : 2,
                                              "advanced" : 0,
                                              "needTime" : 2,
                                              "needFetch" : 0,
                                              "saveState" : 0,
                                              "restoreState" : 0,
                                              "isEOF" : 0,
                                              "invalidates" : 0,
                                              "docsExamined" : 2,
                                              "alreadyHasObj" : 0,
                                              "inputStage" : {
                                                      "stage" : "IXSCAN",
                                                      "nReturned" : 2,
                                                      "executionTimeMillisEstimate" : 0,
                                                      "works" : 2,
                                                      "advanced" : 2,
                                                      "needTime" : 0,
                                                      "needFetch" : 0,
                                                      "saveState" : 0,
                                                      "restoreState" : 0,
                                                      "isEOF" : 0,
                                                      "invalidates" : 0,
                                                      "keyPattern" : {
                                                              "_boundToObjectId" : 1
                                                      },
                                                      "indexName" : "_boundToObjectId_1",
                                                      "isMultiKey" : false,
                                                      "direction" : "forward",
                                                      "indexBounds" : {
                                                              "_boundToObjectId" : [
                                                                      "[ObjectId('572866b38b35ba316d9d41af'), ObjectId('572866b38b35ba316d9d41af')]"
                                                              ]
                                                      },
                                                      "keysExamined" : 2,
                                                      "dupsTested" : 0,
                                                      "dupsDropped" : 0,
                                                      "seenInvalidated" : 0,
                                                      "matchTested" : 0
                                              }
                                      }
                              }
                      },
                      "feedback" : {
      
                      },
                      "filterSet" : false
              },
              {
                      "details" : {
                              "solution" : "(index-tagged expression tree: tree=Node\n---Leaf { _boundToObjectId: 1.0 }, pos: 0\n---Leaf { _teamId: 1.0 }, pos: 0\n---Leaf \n)"
                      },
                      "reason" : {
                              "score" : 1.0002,
                              "stats" : {
                                      "stage" : "LIMIT",
                                      "nReturned" : 0,
                                      "executionTimeMillisEstimate" : 0,
                                      "works" : 2,
                                      "advanced" : 0,
                                      "needTime" : 2,
                                      "needFetch" : 0,
                                      "saveState" : 0,
                                      "restoreState" : 0,
                                      "isEOF" : 0,
                                      "invalidates" : 0,
                                      "limitAmount" : 1,
                                      "inputStage" : {
                                              "stage" : "FETCH",
                                              "filter" : {
                                                      "$and" : [
                                                              {
                                                                      "_boundToObjectId" : {
                                                                              "$eq" : ObjectId("572866b38b35ba316d9d41af")
                                                                      }
                                                              },
                                                              {
                                                                      "_teamId" : {
                                                                              "$eq" : ObjectId("56fb4e0fc6ec2b612e7e6214")
                                                                      }
                                                              },
                                                              {
                                                                      "isQuited" : {
                                                                              "$eq" : false
                                                                      }
                                                              }
                                                      ]
                                              },
                                              "nReturned" : 0,
                                              "executionTimeMillisEstimate" : 0,
                                              "works" : 2,
                                              "advanced" : 0,
                                              "needTime" : 2,
                                              "needFetch" : 0,
                                              "saveState" : 0,
                                              "restoreState" : 0,
                                              "isEOF" : 0,
                                              "invalidates" : 0,
                                              "docsExamined" : 0,
                                              "alreadyHasObj" : 0,
                                              "inputStage" : {
                                                      "stage" : "AND_SORTED",
                                                      "nReturned" : 0,
                                                      "executionTimeMillisEstimate" : 0,
                                                      "works" : 2,
                                                      "advanced" : 0,
                                                      "needTime" : 2,
                                                      "needFetch" : 0,
                                                      "saveState" : 0,
                                                      "restoreState" : 0,
                                                      "isEOF" : 0,
                                                      "invalidates" : 0,
                                                      "flagged" : 0,
                                                      "matchTested" : 0,
                                                      "failedAnd_0" : 0,
                                                      "failedAnd_1" : 0,
                                                      "inputStages" : [
                                                              {
                                                                      "stage" : "IXSCAN",
                                                                      "nReturned" : 1,
                                                                      "executionTimeMillisEstimate" : 0,
                                                                      "works" : 1,
                                                                      "advanced" : 1,
                                                                      "needTime" : 0,
                                                                      "needFetch" : 0,
                                                                      "saveState" : 0,
                                                                      "restoreState" : 0,
                                                                      "isEOF" : 0,
                                                                      "invalidates" : 0,
                                                                      "keyPattern" : {
                                                                              "_boundToObjectId" : 1
                                                                      },
                                                                      "indexName" : "_boundToObjectId_1",
                                                                      "isMultiKey" : false,
                                                                      "direction" : "forward",
                                                                      "indexBounds" : {
                                                                              "_boundToObjectId" : [
                                                                                      "[ObjectId('572866b38b35ba316d9d41af'), ObjectId('572866b38b35ba316d9d41af')]"
                                                                              ]
                                                                      },
                                                                      "keysExamined" : 1,
                                                                      "dupsTested" : 0,
                                                                      "dupsDropped" : 0,
                                                                      "seenInvalidated" : 0,
                                                                      "matchTested" : 0
                                                              },
                                                              {
                                                                      "stage" : "IXSCAN",
                                                                      "nReturned" : 1,
                                                                      "executionTimeMillisEstimate" : 0,
                                                                      "works" : 1,
                                                                      "advanced" : 1,
                                                                      "needTime" : 0,
                                                                      "needFetch" : 0,
                                                                      "saveState" : 0,
                                                                      "restoreState" : 0,
                                                                      "isEOF" : 0,
                                                                      "invalidates" : 0,
                                                                      "keyPattern" : {
                                                                              "_teamId" : 1
                                                                      },
                                                                      "indexName" : "_teamId_1",
                                                                      "isMultiKey" : false,
                                                                      "direction" : "forward",
                                                                      "indexBounds" : {
                                                                              "_teamId" : [
                                                                                      "[ObjectId('56fb4e0fc6ec2b612e7e6214'), ObjectId('56fb4e0fc6ec2b612e7e6214')]"
                                                                              ]
                                                                      },
                                                                      "keysExamined" : 1,
                                                                      "dupsTested" : 0,
                                                                      "dupsDropped" : 0,
                                                                      "seenInvalidated" : 0,
                                                                      "matchTested" : 0
                                                              }
                                                      ]
                                              }
                                      }
                              }
                      },
                      "feedback" : {
      
                      },
                      "filterSet" : false
              }
      ]
      rs0:SECONDARY>                                                            
      
      rs0:SECONDARY> db.members.getPlanCache().clear()
      rs0:SECONDARY> db.members.count({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      76    
      
      {
              "queryPlanner" : {
                      "plannerVersion" : 1,
                      "namespace" : "XXX.members",
                      "indexFilterSet" : false,
                      "parsedQuery" : {
                              "$and" : [
                                      {
                                              "_boundToObjectId" : {
                                                      "$eq" : ObjectId("51762b8f78cfa9f357000011")
                                              }
                                      },
                                      {
                                              "_teamId" : {
                                                      "$eq" : null
                                              }
                                      },
                                      {
                                              "isQuited" : {
                                                      "$eq" : false
                                              }
                                      }
                              ]
                      },
                      "winningPlan" : {
                              "stage" : "FETCH",
                              "filter" : {
                                      "$and" : [
                                              {
                                                      "_teamId" : {
                                                              "$eq" : null
                                                      }
                                              },
                                              {
                                                      "isQuited" : {
                                                              "$eq" : false
                                                      }
                                              }
                                      ]
                              },
                              "inputStage" : {
                                      "stage" : "IXSCAN",
                                      "keyPattern" : {
                                              "_boundToObjectId" : 1
                                      },
                                      "indexName" : "_boundToObjectId_1",
                                      "isMultiKey" : false,
                                      "direction" : "forward",
                                      "indexBounds" : {
                                              "_boundToObjectId" : [
                                                      "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]"
                                              ]
                                      }
                              }
                      },
                      "rejectedPlans" : [ ]
              },
              "executionStats" : {
                      "executionSuccess" : true,
                      "nReturned" : 76,
                      "executionTimeMillis" : 8,
                      "totalKeysExamined" : 92,
                      "totalDocsExamined" : 92,
                      "executionStages" : {
                              "stage" : "FETCH",
                              "filter" : {
                                      "$and" : [
                                              {
                                                      "_teamId" : {
                                                              "$eq" : null
                                                      }
                                              },
                                              {
                                                      "isQuited" : {
                                                              "$eq" : false
                                                      }
                                              }
                                      ]
                              },
                              "nReturned" : 76,
                              "executionTimeMillisEstimate" : 0,
                              "works" : 93,
                              "advanced" : 76,
                              "needTime" : 16,
                              "needFetch" : 0,
                              "saveState" : 0,
                              "restoreState" : 0,
                              "isEOF" : 1,
                              "invalidates" : 0,
                              "docsExamined" : 92,
                              "alreadyHasObj" : 0,
                              "inputStage" : {
                                      "stage" : "IXSCAN",
                                      "nReturned" : 92,
                                      "executionTimeMillisEstimate" : 0,
                                      "works" : 93,
                                      "advanced" : 92,
                                      "needTime" : 0,
                                      "needFetch" : 0,
                                      "saveState" : 0,
                                      "restoreState" : 0,
                                      "isEOF" : 1,
                                      "invalidates" : 0,
                                      "keyPattern" : {
                                              "_boundToObjectId" : 1
                                      },
                                      "indexName" : "_boundToObjectId_1",
                                      "isMultiKey" : false,
                                      "direction" : "forward",
                                      "indexBounds" : {
                                              "_boundToObjectId" : [
                                                      "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]"
                                              ]
                                      },
                                      "keysExamined" : 92,
                                      "dupsTested" : 0,
                                      "dupsDropped" : 0,
                                      "seenInvalidated" : 0,
                                      "matchTested" : 0
                              }
                      }
              },
              "serverInfo" : {
                      "host" : "xxxxx",
                      "port" : 27017,
                      "version" : "3.0.7",
                      "gitVersion" : "6ce7cbe8c6b899552dadd907604559806aa2e9bd"
              },
              "ok" : 1
      }                                                        
      
      Show
      rs0:SECONDARY> db.members.count({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }) 0 rs0:SECONDARY> db.members.find({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }) rs0:SECONDARY> rs0:SECONDARY> db.members.count({ isQuited: false, _teamId:{$exists:false}, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }) 76 rs0:SECONDARY> db.members.find({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }).explain("executionStats") { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "XXX.members", "indexFilterSet" : false, "parsedQuery" : { "$and" : [ { "_boundToObjectId" : { "$eq" : ObjectId("51762b8f78cfa9f357000011") } }, { "_teamId" : { "$eq" : null } }, { "isQuited" : { "$eq" : false } } ] }, "winningPlan" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_teamId" : { "$eq" : null } }, { "isQuited" : { "$eq" : false } } ] }, "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "_boundToObjectId" : 1 }, "indexName" : "_boundToObjectId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_boundToObjectId" : [ "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]" ] } } }, "rejectedPlans" : [ ] }, "executionStats" : { "executionSuccess" : true, "nReturned" : 76, "executionTimeMillis" : 8, "totalKeysExamined" : 92, "totalDocsExamined" : 92, "executionStages" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_teamId" : { "$eq" : null } }, { "isQuited" : { "$eq" : false } } ] }, "nReturned" : 76, "executionTimeMillisEstimate" : 0, "works" : 93, "advanced" : 76, "needTime" : 16, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "docsExamined" : 92, "alreadyHasObj" : 0, "inputStage" : { "stage" : "IXSCAN", "nReturned" : 92, "executionTimeMillisEstimate" : 0, "works" : 93, "advanced" : 92, "needTime" : 0, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "keyPattern" : { "_boundToObjectId" : 1 }, "indexName" : "_boundToObjectId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_boundToObjectId" : [ "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]" ] }, "keysExamined" : 92, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0, "matchTested" : 0 } } }, "serverInfo" : { "host" : "xxxxxxxxxx", "port" : 27017, "version" : "3.0.7", "gitVersion" : "6ce7cbe8c6b899552dadd907604559806aa2e9bd" }, "ok" : 1 } rs0:SECONDARY> db.members.getPlanCache().getPlansByQuery({isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }) [ { "details" : { "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf { _teamId: 1.0 }, pos: 0\n---Leaf \n)" }, "reason" : { "score" : 1.5003000000000002, "stats" : { "stage" : "LIMIT", "nReturned" : 1, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 1, "needTime" : 1, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "limitAmount" : 0, "inputStage" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_boundToObjectId" : { "$eq" : ObjectId("572866b38b35ba316d9d41af") } }, { "isQuited" : { "$eq" : false } } ] }, "nReturned" : 1, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 1, "needTime" : 1, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "docsExamined" : 2, "alreadyHasObj" : 0, "inputStage" : { "stage" : "IXSCAN", "nReturned" : 2, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 2, "needTime" : 0, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "keyPattern" : { "_teamId" : 1 }, "indexName" : "_teamId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_teamId" : [ "[ObjectId('56fb4e0fc6ec2b612e7e6214'), ObjectId('56fb4e0fc6ec2b612e7e6214')]" ] }, "keysExamined" : 2, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0, "matchTested" : 0 } } } }, "feedback" : { "nfeedback" : 20, "averageScore" : NaN, "stdDevScore" : NaN, "scores" : [ { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN }, { "score" : NaN } ] }, "filterSet" : false }, { "details" : { "solution" : "(index-tagged expression tree: tree=Node\n---Leaf { _boundToObjectId: 1.0 }, pos: 0\n---Leaf \n---Leaf \n)" }, "reason" : { "score" : 1.0003, "stats" : { "stage" : "LIMIT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 0, "needTime" : 2, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "limitAmount" : 1, "inputStage" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_teamId" : { "$eq" : ObjectId("56fb4e0fc6ec2b612e7e6214") } }, { "isQuited" : { "$eq" : false } } ] }, "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 0, "needTime" : 2, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "docsExamined" : 2, "alreadyHasObj" : 0, "inputStage" : { "stage" : "IXSCAN", "nReturned" : 2, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 2, "needTime" : 0, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "keyPattern" : { "_boundToObjectId" : 1 }, "indexName" : "_boundToObjectId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_boundToObjectId" : [ "[ObjectId('572866b38b35ba316d9d41af'), ObjectId('572866b38b35ba316d9d41af')]" ] }, "keysExamined" : 2, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0, "matchTested" : 0 } } } }, "feedback" : { }, "filterSet" : false }, { "details" : { "solution" : "(index-tagged expression tree: tree=Node\n---Leaf { _boundToObjectId: 1.0 }, pos: 0\n---Leaf { _teamId: 1.0 }, pos: 0\n---Leaf \n)" }, "reason" : { "score" : 1.0002, "stats" : { "stage" : "LIMIT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 0, "needTime" : 2, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "limitAmount" : 1, "inputStage" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_boundToObjectId" : { "$eq" : ObjectId("572866b38b35ba316d9d41af") } }, { "_teamId" : { "$eq" : ObjectId("56fb4e0fc6ec2b612e7e6214") } }, { "isQuited" : { "$eq" : false } } ] }, "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 0, "needTime" : 2, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "docsExamined" : 0, "alreadyHasObj" : 0, "inputStage" : { "stage" : "AND_SORTED", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 2, "advanced" : 0, "needTime" : 2, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "flagged" : 0, "matchTested" : 0, "failedAnd_0" : 0, "failedAnd_1" : 0, "inputStages" : [ { "stage" : "IXSCAN", "nReturned" : 1, "executionTimeMillisEstimate" : 0, "works" : 1, "advanced" : 1, "needTime" : 0, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "keyPattern" : { "_boundToObjectId" : 1 }, "indexName" : "_boundToObjectId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_boundToObjectId" : [ "[ObjectId('572866b38b35ba316d9d41af'), ObjectId('572866b38b35ba316d9d41af')]" ] }, "keysExamined" : 1, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0, "matchTested" : 0 }, { "stage" : "IXSCAN", "nReturned" : 1, "executionTimeMillisEstimate" : 0, "works" : 1, "advanced" : 1, "needTime" : 0, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 0, "invalidates" : 0, "keyPattern" : { "_teamId" : 1 }, "indexName" : "_teamId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_teamId" : [ "[ObjectId('56fb4e0fc6ec2b612e7e6214'), ObjectId('56fb4e0fc6ec2b612e7e6214')]" ] }, "keysExamined" : 1, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0, "matchTested" : 0 } ] } } } }, "feedback" : { }, "filterSet" : false } ] rs0:SECONDARY> rs0:SECONDARY> db.members.getPlanCache().clear() rs0:SECONDARY> db.members.count({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') }) 76 { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "XXX.members", "indexFilterSet" : false, "parsedQuery" : { "$and" : [ { "_boundToObjectId" : { "$eq" : ObjectId("51762b8f78cfa9f357000011") } }, { "_teamId" : { "$eq" : null } }, { "isQuited" : { "$eq" : false } } ] }, "winningPlan" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_teamId" : { "$eq" : null } }, { "isQuited" : { "$eq" : false } } ] }, "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "_boundToObjectId" : 1 }, "indexName" : "_boundToObjectId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_boundToObjectId" : [ "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]" ] } } }, "rejectedPlans" : [ ] }, "executionStats" : { "executionSuccess" : true, "nReturned" : 76, "executionTimeMillis" : 8, "totalKeysExamined" : 92, "totalDocsExamined" : 92, "executionStages" : { "stage" : "FETCH", "filter" : { "$and" : [ { "_teamId" : { "$eq" : null } }, { "isQuited" : { "$eq" : false } } ] }, "nReturned" : 76, "executionTimeMillisEstimate" : 0, "works" : 93, "advanced" : 76, "needTime" : 16, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "docsExamined" : 92, "alreadyHasObj" : 0, "inputStage" : { "stage" : "IXSCAN", "nReturned" : 92, "executionTimeMillisEstimate" : 0, "works" : 93, "advanced" : 92, "needTime" : 0, "needFetch" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "keyPattern" : { "_boundToObjectId" : 1 }, "indexName" : "_boundToObjectId_1", "isMultiKey" : false, "direction" : "forward", "indexBounds" : { "_boundToObjectId" : [ "[ObjectId('51762b8f78cfa9f357000011'), ObjectId('51762b8f78cfa9f357000011')]" ] }, "keysExamined" : 92, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0, "matchTested" : 0 } } }, "serverInfo" : { "host" : "xxxxx", "port" : 27017, "version" : "3.0.7", "gitVersion" : "6ce7cbe8c6b899552dadd907604559806aa2e9bd" }, "ok" : 1 }
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hey guys
      we met a problem when using the query like this

      db.members.count({ isQuited: false, _teamId: null, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      

      We are using a replica set.
      when we run this query on primary ,it`s ok and returns 76.
      But when we run this query on the secondary ,it returns 0.but when we run a query with null on the other collection ,it`s ok.
      At the same time we can use

      db.members.count({ isQuited: false, _teamId:{$exists:false}, _boundToObjectId: ObjectId('51762b8f78cfa9f357000011') })
      

      this query and return 76.

      But after db.members.getPlanCache().clear() . the query with null is ok!

      but the problem will appear again.

      But the explain return before getPlanCache().clear() is the same with after.

            Assignee:
            Kelsey Schubert
            Reporter:
            liyang zhou
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: