比如这样一个条件:
{ "places.placeId" : "029" , "tribalId" : "10232134"}
数据库是不是先查询一遍"places.placeId" : "029",再查询一遍"tribalId" : "10232134",然后二者取交集?
这个与:
{$and:[ {"places.placeId" : "029"}, {"tribalId" : "10232134"}]}
在查询效率的时候有什么区别?
{ "places.placeId" : "029" , "tribalId" : "10232134"}这是$and写法的简写形式。两者是一样的。
{ "places.placeId" : "029" , "tribalId" : "10232134"} 和
{$and:[ {"places.placeId" : "029"}, {"tribalId" : "10232134"}]} 是等效的, 查询效率没有什么区别。
在没有索引的情况下,匹配时相当于遍历所有数据,然后判断某一条数据是否符合条件即可。