summaryrefslogtreecommitdiff
path: root/jstests/queryoptimizer7.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-06-05 19:50:36 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-06-05 19:50:36 +0200
commit291c9687fb2307dc22d1f269eb4d0aa98fe8cadc (patch)
treef46fac7bf8530d100aa55da89dfaa53490fbb350 /jstests/queryoptimizer7.js
parent6d0f215499dda50fdba4a6f60ab359efe0054e0d (diff)
parent3703a282eca7e79e91f4bd651b1b861b76dc6c68 (diff)
downloadmongodb-291c9687fb2307dc22d1f269eb4d0aa98fe8cadc.tar.gz
Merge tag 'upstream/2.0.6'
Upstream version 2.0.6
Diffstat (limited to 'jstests/queryoptimizer7.js')
-rw-r--r--jstests/queryoptimizer7.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/queryoptimizer7.js b/jstests/queryoptimizer7.js
new file mode 100644
index 0000000..c4ff75b
--- /dev/null
+++ b/jstests/queryoptimizer7.js
@@ -0,0 +1,24 @@
+// Test query retry with a query that is non multikey unusable and unsatisfiable. SERVER-5581
+
+t = db.jstests_queryoptimizer7;
+t.drop();
+
+t.ensureIndex( { a:1 } );
+t.ensureIndex( { b:1 } );
+
+for( i = 0; i < 25; ++i ) {
+ t.save( { a:0, b:'' } ); // a:0 documents have small b strings.
+}
+big = new Array( 1000000 ).toString();
+for( i = 0; i < 50; ++i ) {
+ t.save( { a:[1,3], b:big } ); // a:[1,3] documents have very large b strings.
+}
+
+// Record the a:1 index for the query pattern for { a: { $lt:1 } }, { b:1 }.
+assert.eq( 'BtreeCursor a_1', t.find( { a:{ $lt:1 } } ).sort( { b:1 } ).explain().cursor );
+
+// The multikey query pattern for this query will match that of the previous query.
+// The a:1 index will be retried for this query but fail because an in memory sort must
+// be performed on a larger data set. Because the query { a:{ $lt:2, $gt:2 } } is
+// unsatisfiable, no attempt will be made to clear its query pattern.
+assert.lt( -1, t.find( { a:{ $lt:2, $gt:2 } } ).sort( { b:1 } ).itcount() );