Skip to content

Commit df565d6

Browse files
authored
DOCS-19209 configureCollectionBalancing (#745)
* DOCS-19209 Roughs in new content * DOCS-19209 Adds reference link * DOCS-19209 Nav adjustment * DOCS-19209 configureCOllectionBalancing description * DOCS-19209 Parameter table * DOCS-19209 Example code blocks * DOCS-19209 Adds optional flag * DOCS-19209 Adjusts reference text * DOCS-19209 Expands example text * DOCS-19209 Vale fixes * DOCS-19209 Updates modifying chunk size page for new command * DOCS-19209 Reorder sections on Modify Chunk Size * DOCS-19209 Notes that chunk sizes can be changed for collection * DOCS-19209 Adds version notice * DOCS-19209 Removes version added marker * DOCS-19209 vale checks * DOCS-19209 Navigation fix * DOCS-19209 Internal Review Fixes, per Ian Fogelman * DOCS-19209 Internal Review Fixes, per Ian Fogelman * DOCS-19209 Internal Review Fixes, per Ian Fogelman * DOCS-19209 Internal Review Fixes, per Ian Fogelman * DOCS-19209 Internal Review Fixes, per Ian Fogelman * DOCS-19209 Removes enableAutoSplitter from configureCollectionBalancing doc * DOCS-19209 Further removes changes calling out collection-level autosplit * DOCS-19209 reverts changes on core/charding-data-partitioning * Fixes per Tommaso
1 parent 275b3cf commit df565d6

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

source/reference/command.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,12 @@ Sharding Commands
472472

473473
.. versionadded:: 5.0
474474

475+
* - :dbcommand:`configureCollectionBalancing`
476+
477+
- Configures balancer settings on a sharded collection.
478+
479+
.. versionadded:: 5.3
480+
475481
* - :dbcommand:`enableSharding`
476482

477483
- Enables sharding on a specific database.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
================================
2+
configureCollectionBalancing
3+
================================
4+
5+
.. contents:: On this page
6+
:local:
7+
:backlinks: none
8+
:depth: 1
9+
:class: singlecol
10+
11+
.. meta::
12+
:description: configureCollectionBalancing
13+
:keywords: configureCollectionBalancing
14+
15+
Definition
16+
------------
17+
18+
.. dbcommand:: configureCollectionBalancing
19+
20+
.. versionadded:: 5.3
21+
22+
Configures balancer settings for a sharded collection, such as
23+
setting the chunk size for and defragmenting the collection.
24+
25+
To run :dbcommand:`configureCollectionBalancing`, use the
26+
:method:`db.adminCommand` method:
27+
28+
.. code-block:: none
29+
30+
db.adminCommand( {
31+
configureCollectionBalancing: "<collection>",
32+
chunkSize: <num>,
33+
defragmentCollection: <bool>
34+
} )
35+
36+
:dbcommand:`configureCollectionBalancing` has the following fields:
37+
38+
.. list-table::
39+
:header-rows: 1
40+
:widths: 20 20 80
41+
42+
* - Field
43+
- Type
44+
- Description
45+
* - ``configureCollectionBalancing``
46+
- string
47+
- Required: The name of the database and sharded collection to configure.
48+
* - ``chunkSize``
49+
- integer
50+
- Optional: Sets the chunk size in MiB for the collection.
51+
* - ``defragmentCollection``
52+
- boolean
53+
- Optional: Causes the balancer to defragment the collection.
54+
55+
56+
For more information, see :ref:`Data Partioning with Chunks
57+
<sharding-data-partitioning>`.
58+
59+
Examples
60+
----------
61+
62+
Configure Chunk Size
63+
~~~~~~~~~~~~~~~~~~~~~~
64+
65+
To change the chunk size for a sharded collection, use
66+
the ``chunkSize`` option:
67+
68+
.. code-block:: javascript
69+
70+
db.adminCommand( {
71+
configureCollectionBalancing: "test.students",
72+
chunkSize: 10
73+
} )
74+
75+
Use this command to change the chunk size for the given collection.
76+
77+
.. warning::
78+
79+
By default, MongoDB cannot move a chunk if the number of documents in
80+
the chunk is greater than 1.3 times the result of dividing the
81+
configured chunk size by the average document size.
82+
83+
To find the average document size, see the ``avgObjSize`` field in the
84+
output of the :method:`db.collection.stats()` method.
85+
86+
For more information, see :ref:`Chunk Size <sharding-chunk-size>`.
87+
88+
Defragment Collections
89+
~~~~~~~~~~~~~~~~~~~~~~~~
90+
91+
To tell the balancer to defragment a sharded collection, use the
92+
``defragmentCollection`` option:
93+
94+
.. code-block:: javascript
95+
96+
db.adminCommand( {
97+
configureCollectionBalancing: "test.students",
98+
defragmentCollection: true
99+
} )
100+
101+
Use this command to have the balancer defragment a sharded collection.

source/reference/command/nav-sharding.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ Sharding Commands
8080

8181
.. versionadded:: 5.0
8282

83+
* - :dbcommand:`configureCollectionBalancing`
84+
85+
- Configures balancer settings on a sharded collection.
86+
87+
.. versionadded:: 5.3
88+
8389
* - :dbcommand:`enableSharding`
8490

8591
- Enables sharding on a specific database.
@@ -194,6 +200,7 @@ Sharding Commands
194200
/reference/command/cleanupOrphaned
195201
/reference/command/cleanupReshardCollection
196202
/reference/command/commitReshardCollection
203+
/reference/command/configureCollectionBalancing
197204
/reference/command/enableSharding
198205
/reference/command/flushRouterConfig
199206
/reference/command/getShardMap

0 commit comments

Comments
 (0)