mongodb $与另一个索引字段的位置

时间:2017-06-19 05:45:46

标签: mongodb indexing mongoose mongodb-query

Mongodb doc说$where进行了一次集合扫描,这很糟糕,但如果我在查询中添加一个索引字段,是否会利用索引速度?

db.users.find({
   _id: someMongodbId, 
   $where: function() { return this.name == 'joe' } // ensure this doc has name "joe"
});

在上面的例子中,由于_id字段只有1个查询,对吧?

0 个答案:

没有答案
相关问题