Skip to content

Commit 9df4224

Browse files
Docs 15475 coll mod disabled on bucket namespaces (#2096)
* DOCS-15475 collMod disabled on system.bucket namespace * Updated with tech review feedback * Updated with copy review feedback * Renamed table include to adhere to conventions
1 parent ecb4d80 commit 9df4224

7 files changed

+121
-82
lines changed

source/core/timeseries/timeseries-automatic-removal.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ The result document contains a document for the time series collection
9797
which contains the ``options.expireAfterSeconds`` field.
9898

9999
.. code-block:: javascript
100+
:copyable: false
100101

101102
{
102103
cursor: {

source/core/timeseries/timeseries-best-practices.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ omit the empty fields from your documents.
162162
For example, consider the following documents:
163163

164164
.. code-block:: javascript
165+
:copyable: false
165166
:emphasize-lines: 7
166167

167168
{
@@ -186,6 +187,7 @@ In contrast, the following documents where the empty array is omitted
186187
receive the benefit of optimal compression:
187188

188189
.. code-block:: javascript
190+
:copyable: false
189191

190192
{
191193
time: 2020-01-23T00:00:00.441Z,

source/core/timeseries/timeseries-granularity.txt

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,29 @@ Set Granularity for Time Series Data
1616
:description: Time series, granularity, IOT
1717
:keywords: Time series, granularity, IOT
1818

19+
When you create a :ref:`time series collection
20+
<manual-timeseries-collection>`, MongoDB automatically creates a ``system.buckets``
21+
:ref:`system collection <metadata-system-collections>` based on the ``granularity`` value you specify, and groups
22+
documents into those buckets.
23+
1924
.. note::
2025

2126
You must be running MongoDB 5.0.1 or later in order to change a
2227
time series collection's granularity after the collection has been
2328
created. See :ref:`MongoDB 5.0 known issues
2429
<5.0-known-issue-granularity>`.
2530

26-
When you create a :ref:`time series collection
27-
<manual-timeseries-collection>`, set the granularity to the value that
28-
is the closest match to the time span between consecutive incoming
29-
measurements that have the same unique value for the ``metaField``
30-
field:
31+
The following table shows the maximum time interval included in one
32+
bucket of data when using a given ``granularity`` value:
33+
34+
.. include:: /includes/table-timeseries-granularity-intervals.rst
35+
36+
You can improve performance by setting the ``granularity`` value to the
37+
closest match to the time span between incoming measurements from the
38+
same data source. For example, if you are recording weather data from
39+
thousands of sensors but only record data from each sensor once per 5
40+
minutes, set ``granularity`` to ``"minutes"``. This accurately reflects
41+
the polling interval for a data source.
3142

3243
.. code-block:: javascript
3344

@@ -43,43 +54,11 @@ field:
4354
}
4455
)
4556

46-
Setting the ``granularity`` parameter accurately improves performance by
47-
optimizing how data in the time series collection is stored internally.
48-
49-
To set the parameter accurately, choose a ``granularity`` value that is
50-
closest to the ingestion rate for a unique data source as specified by
51-
the value for the ``metaField`` field.
52-
53-
For example, if your ``metaField`` data identifies weather sensors and
54-
you ingest data from each individual sensor once every 5 minutes, you
55-
should choose ``"minutes"``. Even if you have thousands of sensors and
56-
the data coming in from different sensors is only seconds apart, the
57-
``granularity`` should still be based on the ingestion rate for one
58-
sensor that is uniquely identified by its metadata.
59-
60-
In the following table, you can see the max time span of data that is
61-
stored together for each ``granularity`` value:
62-
63-
.. list-table::
64-
:header-rows: 1
65-
:widths: 40 60
66-
67-
* - ``granularity``
68-
69-
- Covered Time Span
70-
71-
* - ``"seconds"`` (default)
72-
73-
- one hour
74-
75-
* - ``"minutes"``
76-
77-
- 24 hours
78-
79-
* - ``"hours"``
80-
81-
- 30 days
82-
57+
Setting the ``granularity`` to ``hours`` would group up to a month's
58+
worth of data ingest events into a single bucket, resulting in longer
59+
traversal times and slower queries. Setting it to ``seconds``
60+
would lead to multiple buckets per polling interval, many of which
61+
might contain only a single document.
8362

8463
.. seealso::
8564

@@ -100,6 +79,7 @@ The result document contains a document for the time series collection
10079
which contains the ``options.timeseries.granularity`` field.
10180

10281
.. code-block:: javascript
82+
:copyable: false
10383

10484
{
10585
cursor: {
@@ -128,8 +108,8 @@ which contains the ``options.timeseries.granularity`` field.
128108
Change the ``granularity`` of a Time Series Collection
129109
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130110

131-
To change the ``granularity`` parameter value, issue the following
132-
:dbcommand:`collMod` command:
111+
To change the ``granularity`` value, issue the following
112+
:dbcommand:`collMod` command:
133113

134114
.. code-block:: javascript
135115

@@ -138,11 +118,9 @@ To change the ``granularity`` parameter value, issue the following
138118
timeseries: { granularity: "hours" }
139119
})
140120

141-
Once the ``granularity`` is set it can only be increased by one level at
142-
a time. From ``"seconds"`` to ``"minutes"`` or from ``"minutes"`` to
143-
``"hours"``. Other changes are not allowed. If you need to change the
144-
``granularity`` from ``"seconds"`` to ``"hours"``, first increase the
145-
``granularity`` to ``"minutes"`` and then to ``"hours"``.
121+
Once set, you cannot decrease granularity. For example, if granularity
122+
is set to ``minutes``, you can increase it to ``hours``, but you cannot
123+
decrease it to ``seconds``.
146124

147125
.. note::
148126

source/core/timeseries/timeseries-migrate-data-into-timeseries-collection.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ following command:
206206
The command returns the following output:
207207

208208
.. code-block:: javascript
209+
:copyable: false
209210

210211
2021-06-01T16:48:39.980+0200 writing weather.temporarytimeseries to timeseries/weather/temporarytimeseries.bson
211212
2021-06-01T16:48:40.056+0200 done dumping weather.temporarytimeseries (10000 documents)
@@ -224,6 +225,7 @@ collection ``weathernew``, issue the following command:
224225
The command returns the following output:
225226

226227
.. code-block:: javascript
228+
:copyable: false
227229

228230
2021-06-01T16:50:56.639+0200 checking for collection data in timeseries/weather/temporarytimeseries.bson
229231
2021-06-01T16:50:56.640+0200 restoring to existing collection weather.weathernew without dropping

source/core/timeseries/timeseries-procedures.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ command:
4848
``timeseries`` Object Fields
4949
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5050

51-
When creating a time series collection, specify the following options:
51+
When creating a time series collection, set the following fields:
5252

5353
.. list-table::
5454
:header-rows: 1
@@ -240,6 +240,7 @@ measurement and then returns the average of all temperature measurements
240240
that day:
241241

242242
.. code-block:: javascript
243+
:copyable: false
243244

244245
{
245246
"_id" : {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. list-table::
2+
:header-rows: 1
3+
:widths: 40 60
4+
5+
* - ``granularity``
6+
7+
- Covered Time Span
8+
9+
* - ``"seconds"`` (default)
10+
11+
- one hour
12+
13+
* - ``"minutes"``
14+
15+
- 24 hours
16+
17+
* - ``"hours"``
18+
19+
- 30 days

source/reference/command/collMod.txt

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ or view in the current database.
5656
Options
5757
-------
5858

59-
Index Options
60-
~~~~~~~~~~~~~
61-
59+
Change Index Properties
60+
~~~~~~~~~~~~~~~~~~~~~~~
6261

6362
.. collflag:: index
6463

@@ -167,8 +166,8 @@ Index Options
167166

168167
- :ref:`index-type-hidden`
169168

170-
Document Validation
171-
~~~~~~~~~~~~~~~~~~~
169+
Validate Documents
170+
~~~~~~~~~~~~~~~~~~
172171

173172
.. collflag:: validator
174173

@@ -216,8 +215,8 @@ Document Validation
216215
To see an example that uses ``validationAction``, see
217216
:ref:`schema-validation-handle-invalid-docs`.
218217

219-
Views
220-
~~~~~
218+
Modify Views
219+
~~~~~~~~~~~~
221220

222221
.. note::
223222

@@ -258,45 +257,78 @@ Views
258257
{ $project: { user: 1, date: 1, description: 1} } ]
259258
} )
260259

261-
Time Series Collections
262-
~~~~~~~~~~~~~~~~~~~~~~~
260+
Modify Time Series Collections
261+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263262

264-
To enable automatic removal of documents or change the
265-
``expireAfterSeconds`` parameter value for an existing :ref:`time
266-
series collection <manual-timeseries-collection>`, issue the following
267-
:dbcommand:`collMod` command:
263+
.. collflag:: expireAfterSeconds
268264

269-
.. code-block:: javascript
265+
.. note::
270266

271-
db.runCommand( {
272-
collMod: <collection>,
273-
expireAfterSeconds: <Number> || "off"
274-
} )
267+
This is distinct from using the :collflag:`index` option with the
268+
``expireAfterSeconds`` property to change the expiration time
269+
for a :ref:`TTL Collection <ttl-collections>`.
270+
271+
To enable automatic document removal or modify the current
272+
expiration interval for a :ref:`time series collection
273+
<manual-timeseries-collection>`, change the ``expireAfterSeconds``
274+
value:
275275

276-
The ``expireAfterSeconds`` field must be either:
276+
.. code-block:: javascript
277277

278-
- A non-negative decimal number (``>=0``)
279-
- The string ``"off"``.
278+
db.runCommand( {
279+
collMod: <collection>,
280+
expireAfterSeconds: <number> || "off"
281+
} )
280282

281-
A number specifies the number of seconds after which documents expire.
282-
The string ``"off"`` removes the ``expireAfterSeconds`` parameter and
283-
disables automatic removal.
283+
Set ``expireAfterSeconds`` to ``"off"`` to disable automatic removal,
284+
or a non-negative decimal number (``>=0``) to specify the number of
285+
seconds after which documents expire.
284286

285287
.. seealso::
286288

287289
:ref:`manual-timeseries-automatic-removal`
288290

291+
.. collflag:: timeseries-granularity
292+
293+
To modify the :ref:`granularity <timeseries-granularity>` of a time
294+
series collection, change the ``timeseries.granularity`` value:
295+
296+
.. code-block:: javascript
297+
298+
db.runCommand({
299+
collMod: "weather24h",
300+
timeseries: { granularity: "seconds" || "minutes" || "hours" }
301+
})
302+
303+
You cannot decrease granularity. For example, if granularity is set
304+
to ``minutes``, you can increase it to ``hours``, but you cannot
305+
decrease it to ``seconds``.
306+
307+
The following table shows the maximum time interval included in one bucket of data when using a given ``granularity`` value:
308+
309+
.. include:: /includes/table-timeseries-granularity-intervals.rst
310+
311+
.. important::
312+
313+
As with all :ref:`system collections
314+
<metadata-system-collections>`, do not run any operations on the
315+
underlying ``system.buckets`` collection.
316+
317+
.. seealso::
318+
319+
:ref:`timeseries-granularity`
320+
289321
.. _resize-capped-collection:
290322

291323
Resize a Capped Collection
292324
~~~~~~~~~~~~~~~~~~~~~~~~~~
293325

294326
.. versionadded:: 6.0
295327

296-
Starting in MongoDB 6.0, you can resize a capped collection. To change a
297-
:ref:`capped collection's <manual-capped-collection>` maximum size in bytes, use
298-
the ``cappedSize`` option. To change the maximum number of documents in
299-
an existing capped collection, use the ``cappedMax`` option.
328+
Starting in MongoDB 6.0, you can resize a capped collection. To change a
329+
:ref:`capped collection's <manual-capped-collection>` maximum size in
330+
bytes, use the ``cappedSize`` option. To change the maximum number of
331+
documents in an existing capped collection, use the ``cappedMax`` option.
300332

301333
.. note::
302334

@@ -329,9 +361,13 @@ to 100000 bytes and sets the maximum number of documents in the collection to 50
329361
Change Streams with Document Pre- and Post-Images
330362
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
331363

364+
.. versionadded:: 6.0
365+
366+
.. collflag:: changeStreamPreAndPostImages
367+
332368
.. include:: /includes/change-stream-pre-and-post-images-introduction.rst
333369

334-
To use :dbcommand:`collMod` to enable change stream pre- and post-images
370+
To use ``collMod`` to enable change stream pre- and post-images
335371
for a collection, use the ``changeStreamPreAndPostImages`` field:
336372

337373
.. code-block:: javascript
@@ -368,15 +404,15 @@ Write Concern
368404
~~~~~~~~~~~~~
369405

370406
Optional. A document expressing the :doc:`write concern
371-
</reference/write-concern>` of the :dbcommand:`collMod` command.
407+
</reference/write-concern>` of the ``collMod`` command.
372408

373409
Omit to use the default write concern.
374410

375411
Access Control
376412
--------------
377413

378414
If the deployment enforces authentication/authorization, you must have
379-
the following privilege to run the :dbcommand:`collMod` command:
415+
the following privilege to run the ``collMod`` command:
380416

381417
.. list-table::
382418
:header-rows: 1
@@ -580,4 +616,4 @@ entries:
580616
}
581617

582618
To complete the conversion, modify the duplicate entries to remove any
583-
conflicts and re-run ``collMod()`` with the ``unique`` option.
619+
conflicts and re-run ``collMod()`` with the ``unique`` option.

0 commit comments

Comments
 (0)