summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2014-01-17 18:29:02 -0500
committerHari Khalsa <hkhalsa@10gen.com>2014-01-17 18:29:46 -0500
commit5f169de0c5a1651efe39eaa6165c4a3414470dd7 (patch)
treec396458264374c746229727847ec8e8ca23a99fb
parent50b47b93b3bb63e609c55bd45127f49e60919e12 (diff)
downloadmongo-5f169de0c5a1651efe39eaa6165c4a3414470dd7.tar.gz
Revert "SERVER-2094 distinct only wants the field it's distinct-ing over"
This reverts commit 3b5b31f42d390e9da23f66e78a300d997ae653c4.
-rw-r--r--jstests/distinct_index1.js12
-rw-r--r--src/mongo/db/commands/distinct.cpp16
2 files changed, 12 insertions, 16 deletions
diff --git a/jstests/distinct_index1.js b/jstests/distinct_index1.js
index e6687d7b762..9e2089858b9 100644
--- a/jstests/distinct_index1.js
+++ b/jstests/distinct_index1.js
@@ -37,11 +37,14 @@ t.ensureIndex( { a : 1 } )
x = d( "a" );
assert.eq( 1000 , x.stats.n , "BA1" )
assert.eq( 1000 , x.stats.nscanned , "BA2" )
+// QUERY_MIGRATION: pending projection support
+//assert.eq( 0 , x.stats.nscannedObjects , "BA3" )
x = d( "a" , { a : { $gt : 5 } } );
assert.eq( 398 , x.stats.n , "BB1" )
assert.eq( 398 , x.stats.nscanned , "BB2" )
-assert.eq( 0 , x.stats.nscannedObjects , "BB3" )
+// QUERY_MIGRATION: pending projection support
+// assert.eq( 0 , x.stats.nscannedObjects , "BB3" )
x = d( "b" , { a : { $gt : 5 } } );
assert.eq( 398 , x.stats.n , "BC1" )
@@ -52,5 +55,10 @@ assert.eq( 398 , x.stats.nscannedObjects , "BC3" )
t.dropIndexes();
t.ensureIndex( { a : 1, b : 1 } );
x = d( "b" , { a : { $gt : 5 }, b : { $gt : 5 } } );
+// QUERY_MIGRATION: we show the actual cursor used
+// assert.eq( "QueryOptimizerCursor", x.stats.cursor );
assert.eq( 171 , x.stats.n )
-assert.eq( 0 , x.stats.nscannedObjects , "BB3" )
+// QUERY_MIGRATION: our nscanned is lower...
+// assert.eq( 275 , x.stats.nscanned )
+// Disable temporarily - exact value doesn't matter.
+// assert.eq( 266 , x.stats.nscannedObjects )
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 503beedf4dc..f22a407a941 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -100,15 +100,8 @@ namespace mongo {
}
CanonicalQuery* cq;
-
- // We only care about the field that we're projecting over. Have to drop the _id field
- // explicitly because those are .find() semantics.
- //
- // Applying a projection allows the planner to try to give us covered plans.
- BSONObj projection = BSON("_id" << 0 << key << 1);
-
- // Apply a projection of the key. Empty BSONObj() is for the sort.
- if (!CanonicalQuery::canonicalize(ns, query, BSONObj(), projection, &cq).isOK()) {
+ // XXX: project out just the field we're distinct-ing. May be covered...
+ if (!CanonicalQuery::canonicalize(ns, query, &cq).isOK()) {
uasserted(17215, "Can't canonicalize query " + query.toString());
return 0;
}
@@ -127,11 +120,6 @@ namespace mongo {
BSONObj obj;
Runner::RunnerState state;
while (Runner::RUNNER_ADVANCED == (state = runner->getNext(&obj, NULL))) {
- // Distinct expands arrays.
- //
- // If our query is covered, each value of the key should be in the index key and
- // available to us without this. If a collection scan is providing the data, we may
- // have to expand an array.
BSONElementSet elts;
obj.getFieldsDotted(key, elts);