summaryrefslogtreecommitdiff
path: root/jstests/core/sortf.js
blob: 47c6a27ed9f4e538e4bd5b57e5f370d7c4ca6c30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// @tags: [
//   requires_getmore,
// ]

// Unsorted plan on {a:1}, sorted plan on {b:1}.  The unsorted plan exhausts its memory limit before
// the sorted plan is chosen by the query optimizer.

t = db.jstests_sortf;
t.drop();

t.createIndex({a: 1});
t.createIndex({b: 1});

for (i = 0; i < 100; ++i) {
    t.save({a: 0, b: 0});
}

big = new Array(10 * 1000 * 1000).toString();
for (i = 0; i < 5; ++i) {
    t.save({a: 1, b: 1, big: big});
}

assert.eq(5, t.find({a: 1}).sort({b: 1}).itcount());
t.drop();