File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -162,14 +162,17 @@ storage efficiently in such situations.
162
162
163
163
- Use the ``_id`` field explicitly.
164
164
165
- MongoDB automatically adds an :term:`ObjectId` to each document and sets it to
165
+ MongoDB clients automatically add an :term:`ObjectId` to each document and set it to
166
166
a unique value. Additionally this field in indexed. For tiny documents
167
- this takes up significant space. To optimize, use the ``_id``
168
- explicitly. Take a field that is unique for the collection and store
169
- its values in ``_id``. By doing so, you have explicitly provided IDs.
170
- This eliminates the creation of a separate ``_id`` field. If your
171
- previously separate field was indexed, this eliminates an extra index,
172
- too.
167
+ this takes up significant space.
168
+
169
+ To optimize, users can provide a value for the ``_id`` field
170
+ explicitly. The goal is to leverage the ``_id`` field to store a value
171
+ that would have occupied space in another portion of the document. The
172
+ only requirement for the ``_id`` field value is that it must serve as
173
+ a primary key for documents in the collection by uniquely identifying
174
+ them. If the field's value is not unique, then it cannot serve as a
175
+ primary key as there would be collisions in the namespace.
173
176
174
177
- Use shorter field names. This is recommended only in certain situations.
175
178
You can’t perform that action at this time.
0 commit comments