2014-08-27 15:36:08 -04:00
|
|
|
// Test that limit is applied by explain.
|
2012-02-14 09:30:08 -08:00
|
|
|
|
|
|
|
|
t = db.jstests_explain4;
|
|
|
|
|
t.drop();
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.ensureIndex({a: 1});
|
2012-02-14 09:30:08 -08:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
for (i = 0; i < 10; ++i) {
|
|
|
|
|
t.save({a: i, b: 0});
|
2012-02-14 09:30:08 -08:00
|
|
|
}
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
explain = t.find({a: {$gte: 0}, b: 0}).sort({a: 1}).hint({a: 1}).limit(5).explain(true);
|
2012-03-13 21:20:49 -07:00
|
|
|
|
2014-08-27 15:36:08 -04:00
|
|
|
// Five results are expected, matching the limit spec.
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(5, explain.executionStats.nReturned);
|