在$奇怪我有一個包含30 mongoid一個數組,這是我的代碼,蒙戈DB在
$rest = $m->cart->res->find(array("_id" => array('$in' => $restin["e"])))->limit(30)->explain();
_id場自然是索引,但我得到的結果就像它從來沒有索引,這是我的解釋結果,
[cursor] => BtreeCursor _id_ multi
[isMultiKey] =>
[n] => 30
[nscannedObjects] => 30
[nscanned] => 43
[nscannedObjectsAllPlans] => 30
[nscannedAllPlans] => 43
[scanAndOrder] =>
[indexOnly] =>
[nYields] => 0
[nChunkSkips] => 0
[millis] => 0
[indexBounds] => Array
我不明白的部分是,爲什麼MongoDB的搜索43個文件?,只有30索引mongoids,nscanned應該是30,我怎麼能解決這個問題?
嘗試沒有限制,看看是否改變解釋計劃 – muruga
仍然沒有改變 – user1794257
你很確定你的數組只有30個元素?順便說一下,你的MongoDB版本是什麼? – muruga