summaryrefslogtreecommitdiff
path: root/jstests/index_check2.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-06-03 16:15:58 -0400
committerEliot Horowitz <eliot@10gen.com>2009-06-03 16:15:58 -0400
commite448d675b987015049f0a3c374a92f7f20c05d33 (patch)
tree4392ac9443cd781dd75606970039bda21e904660 /jstests/index_check2.js
parent4d77758502e0a8b5fceb2c1b3c58718e06377a2f (diff)
downloadmongo-e448d675b987015049f0a3c374a92f7f20c05d33.tar.gz
broken query optimizer test
Diffstat (limited to 'jstests/index_check2.js')
-rw-r--r--jstests/index_check2.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/jstests/index_check2.js b/jstests/index_check2.js
new file mode 100644
index 00000000000..e714d1c2d36
--- /dev/null
+++ b/jstests/index_check2.js
@@ -0,0 +1,31 @@
+
+t = db.index_check2;
+t.drop();
+
+for ( var i=0; i<1000; i++ ){
+ var a = [];
+ for ( var j=1; j<5; j++ ){
+ a.push( "tag" + ( i * j % 50 ));
+ }
+ t.save( { num : i , tags : a } );
+}
+
+q1 = { tags : "tag6" };
+q2 = { tags : { $all : [ "tag6" , "tag12" ] } }
+
+assert.eq( 120 , t.find( q1 ).itcount() );
+assert.eq( 60 , t.find( q2 ).itcount() );
+
+t.ensureIndex( { tags : 1 } );
+
+assert.eq( 120 , t.find( q1 ).itcount() );
+assert.eq( 60 , t.find( q2 ).itcount() );
+
+assert.eq( "BtreeCursor tags_1" , t.find( q1 ).explain().cursor );
+assert.eq( "BtreeCursor tags_1" , t.find( q2 ).explain().cursor );
+
+scanned1 = t.find(q1).explain().nscanned;
+scanned2 = t.find(q2).explain().nscanned;
+
+//assert( scanned2 <= scanned1 , "$all makes query optimizer not work well" );
+