的MongoDB/Mongoid查询缓慢我有一个mongoid模式是这样的:在索引属性
class Link
include Mongoid::Document
include Mongoid::Timestamps
field :url, type: String
index :url, background: true
end
现在我有2个查询与分析打开:
Link.where(url: "http://stackoverflow.com/questions/ask").first # =># <Link _id .....>
执行的< 1ms的,没有缓慢的记录
Link.where(url: "no url").first # =># nil
执行= 35MS * PROFILER :: * 日10月9日23时36分二十秒[conn20]查询ccc7.links ntoreturn:1 nscanned:16402个reslen:20 35MS
我的问题:
明确索引工作正常,但为什么一个不存在将mongodb这么长时间查询?甚至扫过整个mongo系列?是不是索引照顾这个?
当您在mongo shell上执行查询时,mongodb查询解释会显示什么内容? db.link.find({url:“no url”})。explain() – rit