summaryrefslogtreecommitdiff
path: root/jstests/explain7.js
blob: 97998d712482f9e6ff1ccee25d58fac32fd5f2bc (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Basic test for special explain fields of a geo cursor.

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

function checkFields( expected, explain ) {
//    printjson( explain );
    for( e in expected ) {
        assert.eq( expected[ e ], explain[ e ], e );
    }
}

t.ensureIndex( { loc:'2d' } );
checkFields( {
            lookedAt:0,
            matchesPerfd:0,
            objectsLoaded:0,
            pointsLoaded:0,
            pointsSavedForYield:0,
            pointsChangedOnYield:0,
            pointsRemovedOnYield:0
            },
            t.find( { loc:[ 1, 5 ] } ).explain( true ) );

t.save( { loc: [ 1, 4 ] } );
t.save( { loc: [ 1, 5 ] } );
checkFields( {
            lookedAt:1,
            matchesPerfd:0,
            objectsLoaded:1,
            pointsLoaded:1,
            pointsSavedForYield:0,
            pointsChangedOnYield:0,
            pointsRemovedOnYield:0
            },
            t.find( { loc:[ 1, 5 ] } ).explain( true ) );

t.save( { loc: [ 1, 5 ] } );
checkFields( {
            n:1,
            lookedAt:2,
            matchesPerfd:0,
            objectsLoaded:2,
            pointsLoaded:2,
            pointsSavedForYield:0,
            pointsChangedOnYield:0,
            pointsRemovedOnYield:0
            },
            t.find( { loc:[ 1, 5 ] } ).limit( 1 ).explain( true ) );