Note that there are some explanatory texts on larger screens.

plurals
  1. POSharding do not balance data to two shards
    primarykey
    data
    text
    <p>I have added two shards as follows:</p> <pre><code> shards: { "_id" : "rs0", "host" : "rs0/serv1:27017,serv2:27017,serv3:27017" } { "_id" : "rs1", "host" : "rs1/serv3:27017,serv4:27017,serv5:27017" } </code></pre> <p>I have sharded my collection posts as follows:</p> <p>databases:</p> <pre><code>{ "_id" : "mypost", "partitioned" : true, "primary" : "rs0" } mypost.posts shard key: { "_id" : "hashed" } chunks: rs0 2 { "_id" : { "$minKey" : 1 } } --&gt;&gt; { "_id" : NumberLong(0) } on : rs0 Timestamp(1, 0) { "_id" : NumberLong(0) } --&gt;&gt; { "_id" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 1) </code></pre> <p>My question is even though I use hashed key on _id and inserted 34MB of data why data is always fetched from shard 1 only and no chunk is moved to shard 2.</p> <p>when I do</p> <pre><code>db.posts.find().explain() i get: { "clusteredType" : "ParallelSort", "shards" : { "rs0/serv1:27017,serv2:27017,serv3:27017" : [ { "cursor" : "BasicCursor", "isMultiKey" : false, "n" : 1000, "nscannedObjects" : 1000, "nscanned" : 1000, "nscannedObjectsAllPlans" : 1000, "nscannedAllPlans" : 1000, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 4, "indexBounds" : { }, "server" : "serv1:27017" } ] }, "cursor" : "BasicCursor", "n" : 1000, "nChunkSkips" : 0, "nYields" : 0, "nscanned" : 1000, "nscannedAllPlans" : 1000, "nscannedObjects" : 1000, "nscannedObjectsAllPlans" : 1000, "millisShardTotal" : 4, "millisShardAvg" : 4, "numQueries" : 1, "numShards" : 1, "indexBounds" : { }, "millis" : 5 } </code></pre> <p>How can my data be sent to both the shard automatically.</p> <p>sh.status()</p> <pre><code> sharding version: { "_id" : 1, "version" : 3, "minCompatibleVersion" : 3, "currentVersion" : 4, "clusterId" : ObjectId("50fde9a8552b8ce5c47c8ead") } shards: { "_id" : "rs0", "host" : "rs0/serv1:27017,serv2:27017,serv3:27017" } { "_id" : "rs1", "host" : "rs1/serv4:27017,serv5:27017,serv6:27017" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "myposts", "partitioned" : true, "primary" : "rs0" } myposts.posts shard key: { "_id" : "hashed" } chunks: rs0 1 { "_id" : { "$minKey" : 1 } } --&gt;&gt; { "_id" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 0) </code></pre> <p>status after delete of collection---------------------</p> <pre><code>{ "_id" : "myposts", "partitioned" : true, "primary" : "rs0" } myposts.posts shard key: { "_id" : "hashed" } chunks: rs0 2 { "_id" : { "$minKey" : 1 } } --&gt;&gt; { "_id" : NumberLong(0) } on : rs0 Timestamp(1, 0) { "_id" : NumberLong(0) } --&gt;&gt; { "_id" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 1) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload