~ubuntu-branches/ubuntu/utopic/mongodb/utopic

« back to all changes in this revision

Viewing changes to jstests/explainb.js

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-07-03 09:23:46 UTC
  • mfrom: (1.3.10) (44.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20140703092346-c5bvt46wnzougyly
Tags: 1:2.6.3-0ubuntu1
* New upstream stable release:
  - Dropped patches, included upstream:
    + 0003-All-platforms-but-Windows-find-hash-in-std-tr1.patch
    + 0008-Use-system-libstemmer.patch
    + 0011-Use-a-signed-char-to-store-BSONType-enumerations.patch
    + 0001-SERVER-12064-Atomic-operations-for-gcc-non-Intel-arc.patch
    + 0002-SERVER-12065-Support-ARM-and-AArch64-builds.patch
  - d/p/*: Refreshed/rebased remaining patches.
  - Use system provided libyaml-cpp:
    + d/control: Add libyaml-cpp-dev to BD's.
    + d/rules: Enable --with-system-yaml option.
    + d/p/fix-yaml-detection.patch: Fix detection of libyaml-cpp library.
  - d/mongodb-server.mongodb.upstart: Sync changes from upstream.
  - d/control,mongodb-dev.*: Drop mongodb-dev package; it has no reverse
    dependencies and upstream no longer install header files.
  - d/NEWS: Point users to upstream upgrade documentation for upgrades
    from 2.4 to 2.6.
* Merge from Debian unstable.
* d/control: BD on libv8-3.14-dev to ensure that transitioning to new v8
  versions is a explicit action due to changes in behaviour in >= 3.25
  (LP: #1295723).
* d/mongodb-server.prerm: Dropped debug echo call from maintainer script
  (LP: #1294455).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// nscanned and nscannedObjects report results for the winning plan; nscannedAllPlans and
2
 
// nscannedObjectsAllPlans report results for all plans.  SERVER-6268
3
 
 
4
 
t = db.jstests_explainb;
5
 
t.drop();
6
 
 
7
 
t.ensureIndex( { a:1, b:1 } );
8
 
t.ensureIndex( { b:1, a:1 } );
9
 
 
10
 
t.save( { a:0, b:1 } );
11
 
t.save( { a:1, b:0 } );
12
 
 
13
 
explain = t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).explain( true );
14
 
 
15
 
// The a:1,b:1 plan finishes scanning first.
16
 
assert.eq( 'BtreeCursor a_1_b_1', explain.cursor );
17
 
assert.eq( 2, explain.n );
18
 
// nscanned and nscannedObjects are reported for the a:1,b:1 plan.
19
 
assert.eq( 2, explain.nscanned );
20
 
assert.eq( 2, explain.nscannedObjects );
21
 
// nscannedAllPlans reports the combined total of all plans.
22
 
assert.eq( 6, explain.nscannedAllPlans );
23
 
// nscannedObjectsAllPlans reports the total for the set of interleaved plans.
24
 
assert.eq( 4, explain.nscannedObjectsAllPlans );
25
 
 
26
 
// A limit of 2.
27
 
explain = t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).limit( -2 ).explain( true );
28
 
 
29
 
assert.eq( 'BtreeCursor a_1_b_1', explain.cursor );
30
 
assert.eq( 2, explain.n );
31
 
assert.eq( 1, explain.nscanned );
32
 
assert.eq( 1, explain.nscannedObjects );
33
 
// The first result was identified for each plan.
34
 
assert.eq( 3, explain.nscannedAllPlans );
35
 
// One result was retrieved from each of the two indexed plans.
36
 
assert.eq( 2, explain.nscannedObjectsAllPlans );
37
 
 
38
 
// A $or query.
39
 
explain = t.find( { $or:[ { a:{ $gte:0 }, b:{ $gte:1 } },
40
 
                          { a:{ $gte:1 }, b:{ $gte:0 } } ] } ).explain( true );
41
 
assert.eq( 1, explain.clauses[ 0 ].n );
42
 
assert.eq( 1, explain.clauses[ 0 ].nscannedObjects );
43
 
assert.eq( 2, explain.clauses[ 0 ].nscanned );
44
 
assert.eq( 2, explain.clauses[ 0 ].nscannedObjectsAllPlans );
45
 
assert.eq( 4, explain.clauses[ 0 ].nscannedAllPlans );
46
 
assert.eq( 1, explain.clauses[ 1 ].n );
47
 
assert.eq( 1, explain.clauses[ 1 ].nscannedObjects );
48
 
assert.eq( 1, explain.clauses[ 1 ].nscanned );
49
 
assert.eq( 2, explain.clauses[ 1 ].nscannedObjectsAllPlans );
50
 
assert.eq( 3, explain.clauses[ 1 ].nscannedAllPlans );
51
 
assert.eq( 2, explain.n );
52
 
 
53
 
// These are computed by summing the values for each clause.
54
 
assert.eq( 2, explain.n );
55
 
assert.eq( 2, explain.nscannedObjects );
56
 
assert.eq( 3, explain.nscanned );
57
 
assert.eq( 4, explain.nscannedObjectsAllPlans );
58
 
assert.eq( 7, explain.nscannedAllPlans );
59
 
 
60
 
// A non $or case where nscanned != nscannedObjects.
61
 
t.remove();
62
 
 
63
 
t.save( { a:'0', b:'1' } );
64
 
t.save( { a:'1', b:'0' } );
65
 
 
66
 
explain = t.find( { a:/0/, b:/1/ } ).explain( true );
67
 
 
68
 
assert.eq( 'BtreeCursor a_1_b_1 multi', explain.cursor );
69
 
assert.eq( 1, explain.n );
70
 
assert.eq( 2, explain.nscanned );
71
 
assert.eq( 1, explain.nscannedObjects );
72
 
// Two results were scanned for each plan.
73
 
assert.eq( 6, explain.nscannedAllPlans );
74
 
// One result was generated by { a:1, b:1 }.  One result was matched by { b:1, a:1 } but it was a
75
 
// dup.  Two results were loaded for matching by the unindexed plan.
76
 
assert.eq( 3, explain.nscannedObjectsAllPlans );