summaryrefslogtreecommitdiff
path: root/jstests/core/collation.js
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2016-08-17 11:13:58 -0400
committerDavid Storch <david.storch@10gen.com>2016-08-18 17:46:12 -0400
commitbc8096859cdd734012d76e4e192f427ac94e48d7 (patch)
tree9f7bd7dfd4ed9955c4e92fb04e20904b8a130330 /jstests/core/collation.js
parent45d31b50bd1669116248bae73d25769505e62acb (diff)
downloadmongo-bc8096859cdd734012d76e4e192f427ac94e48d7.tar.gz
SERVER-24401 allow DISTINCT_SCAN plans over collator comparison keys
Diffstat (limited to 'jstests/core/collation.js')
-rw-r--r--jstests/core/collation.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/core/collation.js b/jstests/core/collation.js
index c682a47e7bc..20df0f73489 100644
--- a/jstests/core/collation.js
+++ b/jstests/core/collation.js
@@ -470,6 +470,27 @@
assert.commandWorked(coll.ensureIndex({a: 1}, {collation: {locale: "en_US"}}));
var explain = coll.explain("queryPlanner").distinct("a");
assert(planHasStage(explain.queryPlanner.winningPlan, "DISTINCT_SCAN"));
+ assert(planHasStage(explain.queryPlanner.winningPlan, "FETCH"));
+
+ // Distinct scan on strings can be used over an index with a collation when the predicate has
+ // exact bounds.
+ explain = coll.explain("queryPlanner").distinct("a", {a: {$gt: "foo"}});
+ assert(planHasStage(explain.queryPlanner.winningPlan, "DISTINCT_SCAN"));
+ assert(planHasStage(explain.queryPlanner.winningPlan, "FETCH"));
+ assert(!planHasStage(explain.queryPlanner.winningPlan, "PROJECTION"));
+
+ // Distinct scan cannot be used over an index with a collation when the predicate has inexact
+ // bounds.
+ explain = coll.explain("queryPlanner").distinct("a", {a: {$exists: true}});
+ assert(planHasStage(explain.queryPlanner.winningPlan, "IXSCAN"));
+ assert(planHasStage(explain.queryPlanner.winningPlan, "FETCH"));
+ assert(!planHasStage(explain.queryPlanner.winningPlan, "DISTINCT_SCAN"));
+
+ // Distinct scan can be used without a fetch when predicate has exact non-string bounds.
+ explain = coll.explain("queryPlanner").distinct("a", {a: {$gt: 3}});
+ assert(planHasStage(explain.queryPlanner.winningPlan, "DISTINCT_SCAN"));
+ assert(planHasStage(explain.queryPlanner.winningPlan, "PROJECTION"));
+ assert(!planHasStage(explain.queryPlanner.winningPlan, "FETCH"));
// Distinct should not use index when no collation specified and collection default collation is
// incompatible with index collation.