diff options
author | Aaron <aaron@10gen.com> | 2010-08-18 11:42:58 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-08-18 11:42:58 -0700 |
commit | fe7a8dfaf48e167a5cfeed4aa1b27ae803623688 (patch) | |
tree | f370905997c9e2edec477d7e53517bf3341546fb /jstests/indexj.js | |
parent | fef8cb5de84145b5eee7281d41e351832af02633 (diff) | |
download | mongo-fe7a8dfaf48e167a5cfeed4aa1b27ae803623688.tar.gz |
SERVER-726 optimize exclusive bounds
Diffstat (limited to 'jstests/indexj.js')
-rw-r--r-- | jstests/indexj.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/jstests/indexj.js b/jstests/indexj.js new file mode 100644 index 00000000000..0d1afc29b50 --- /dev/null +++ b/jstests/indexj.js @@ -0,0 +1,44 @@ +// SERVER-726 + +t = db.jstests_indexj; +t.drop(); + +t.ensureIndex( {a:1} ); +t.save( {a:5} ); +assert.eq( 0, t.find( { a: { $gt:4, $lt:5 } } ).explain().nscanned, "A" ); + +t.drop(); +t.ensureIndex( {a:1} ); +t.save( {a:4} ); +assert.eq( 0, t.find( { a: { $gt:4, $lt:5 } } ).explain().nscanned, "B" ); + +t.save( {a:5} ); +assert.eq( 0, t.find( { a: { $gt:4, $lt:5 } } ).explain().nscanned, "D" ); + +t.save( {a:4} ); +assert.eq( 0, t.find( { a: { $gt:4, $lt:5 } } ).explain().nscanned, "C" ); + +t.save( {a:5} ); +assert.eq( 0, t.find( { a: { $gt:4, $lt:5 } } ).explain().nscanned, "D" ); + +t.drop(); +t.ensureIndex( {a:1,b:1} ); +t.save( { a:1,b:1 } ); +t.save( { a:1,b:2 } ); +t.save( { a:2,b:1 } ); +t.save( { a:2,b:2 } ); + +assert.eq( 2, t.find( { a:{$in:[1,2]}, b:{$gt:1,$lt:2} } ).explain().nscanned ); +assert.eq( 2, t.find( { a:{$in:[1,2]}, b:{$gt:1,$lt:2} } ).sort( {a:-1,b:-1} ).explain().nscanned ); + +t.save( {a:1,b:1} ); +t.save( {a:1,b:1} ); +assert.eq( 2, t.find( { a:{$in:[1,2]}, b:{$gt:1,$lt:2} } ).explain().nscanned ); +assert.eq( 2, t.find( { a:{$in:[1,2]}, b:{$gt:1,$lt:2} } ).explain().nscanned ); +assert.eq( 2, t.find( { a:{$in:[1,2]}, b:{$gt:1,$lt:2} } ).sort( {a:-1,b:-1} ).explain().nscanned ); + +assert.eq( 1, t.find( { a:{$in:[1,1.9]}, b:{$gt:1,$lt:2} } ).explain().nscanned ); +assert.eq( 1, t.find( { a:{$in:[1.1,2]}, b:{$gt:1,$lt:2} } ).sort( {a:-1,b:-1} ).explain().nscanned ); + +t.save( { a:1,b:1.5} ); +assert.eq( 3, t.find( { a:{$in:[1,2]}, b:{$gt:1,$lt:2} } ).explain().nscanned, "F" ); |