File: indexo.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (32 lines) | stat: -rw-r--r-- 963 bytes parent folder | download | duplicates (4)
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
// Check that dummy basic cursors work correctly SERVER-958.

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

function checkDummyCursor( explain ) {
 	assert.eq( "BasicCursor", explain.cursor );
    assert.eq( 0, explain.nscanned );
    assert.eq( 0, explain.n );
}

t.save( {a:1} );

t.ensureIndex( {a:1} );

// Match is impossible, so no documents should be scanned.
checkDummyCursor( t.find( {a:{$gt:5,$lt:0}} ).explain() );

t.drop();
checkDummyCursor( t.find( {a:1} ).explain() );

t.save( {a:1} );
t.ensureIndex( {a:1} );
checkDummyCursor( t.find( {$or:[{a:{$gt:5,$lt:0}},{a:1}]} ).explain().clauses[ 0 ] );

t.drop();
t.save( {a:5,b:[1,2]} );
t.ensureIndex( {a:1,b:1} );
t.ensureIndex( {a:1} );
// The first clause will use index {a:1,b:1} with the current implementation.
// The second clause has no valid values for index {a:1} so it will use a dummy cursor.
checkDummyCursor( t.find( {$or:[{b:{$exists:true},a:{$gt:4}},{a:{$lt:6,$gt:4}}]} ).explain().clauses[ 1 ] );