【发布时间】:2014-05-08 09:50:05
【问题描述】:
我需要找到最近的元素,字段“data_caricamento”保存日期。 所以我用 MognoDb shell 做了一个索引:
db.collection.ensureIndex({"data_caricamento": -1})
下面的php代码我有我需要的东西
$cursor=$collection->find();
$cursor->sort(array("data_caricamento"=> -1));
$cursor->limit($n);
但我认为这应该是一个更好的方法, 例如有没有办法直接查询索引? 谢谢。
【问题讨论】:
标签: php mongodb query-optimization mongodb-php