Why $in is much faster than $all?

前端 未结 2 1050
孤城傲影
孤城傲影 2021-01-28 02:30
db.tablebusiness.find({ \"LongitudeLatitude\" : { \"$nearSphere\" : [106.772835, -6.186753], \"$maxDistance\" : 0.053980478460939611 }, \"Prominent\" : { \"$gte\" : 15 }         


        
2条回答
  •  -上瘾入骨i
    2021-01-28 02:35

    You are comparing apples with oranges. Both queries return different results. $all means that the field value should match all the inputs whereas $in means that the field value should match any one of the values. $all is and, $in is or.

    Combined with the $limit - the $all query will need to look at more documents to find the match as compared to in.

提交回复
热议问题