Skip to content

Commit e91407c

Browse files
Docsp 28718 forwardport (#3144)
* Codeblock rendering fix * Self proofreading * Clarified restrictions on bucketing parameters * Switching to procedure directive * Switching to procedure directive * Internal PR feedback * Internal review feedback * Internal review feedback--amend * Internal review feedback--amend * Internal review feedback--amend * External review feedback * Merge cleanup
1 parent 71a47ed commit e91407c

File tree

4 files changed

+129
-141
lines changed

4 files changed

+129
-141
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,33 +215,33 @@ Optimize Query Performance
215215

216216
Set Appropriate Bucket Granularity
217217
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218-
When you create a :ref:`time series collection
219-
<manual-timeseries-collection>`, MongoDB groups incoming time series
220-
data into buckets. By accurately setting granularity, you control how
221-
frequently data is bucketed based on the ingestion rate of your data.
218+
When you create a time series collection, MongoDB groups incoming time
219+
series data into buckets. By accurately setting granularity, you control
220+
how frequently data is bucketed based on the ingestion rate of your data.
222221

223222
Starting in MongoDB 6.3, you can use the custom bucketing parameters
224223
``bucketMaxSpanSeconds`` and ``bucketRoundingSeconds`` to specify bucket
225-
boundaries and more accurately control how time series data is bucketed.
224+
boundaries and more precisely control how time series data is bucketed.
226225

227226
You can improve performance by setting the ``granularity`` or custom
228227
bucketing parameters to the best match for the time span between
229228
incoming measurements from the same data source. For example, if you are
230229
recording weather data from thousands of sensors but only record data
231230
from each sensor once per 5 minutes, you can either set ``granularity``
232-
to ``"minutes"`` or set the custom bucketing parameters to ``300`` (seconds).
233-
234-
The following table shows the maximum time interval included in one
235-
bucket of data when using a given ``granularity`` value:
236-
237-
.. include:: /includes/table-timeseries-granularity-intervals.rst
231+
to ``"minutes"`` or set the custom bucketing parameters to ``300``
232+
(seconds).
238233

239234
In this case, setting the ``granularity`` to ``hours`` groups up to a
240235
month's worth of data ingest events into a single bucket, resulting in
241236
longer traversal times and slower queries. Setting it to ``seconds``
242237
leads to multiple buckets per polling interval, many of which
243238
might contain only a single document.
244239

240+
The following table shows the maximum time interval included in one
241+
bucket of data when using a given ``granularity`` value:
242+
243+
.. include:: /includes/table-timeseries-granularity-intervals.rst
244+
245245
.. seealso::
246246

247247
:ref:`Timing of Automatic Removal

source/core/timeseries/timeseries-granularity.txt

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ 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
21-
``system.buckets`` :ref:`system collection
19+
When you create a time series collection, MongoDB automatically creates
20+
a ``system.buckets`` :ref:`system collection
2221
<metadata-system-collections>` and groups incoming time series data
2322
into buckets. By setting granularity, you control how
2423
frequently data is bucketed based on the ingestion rate of your data.
@@ -34,7 +33,7 @@ boundaries and more accurately control how time series data is bucketed.
3433
created. See :ref:`MongoDB 5.0 known issues
3534
<5.0-known-issue-granularity>`.
3635

37-
Retrieve the Current bucketing parameters
36+
Retrieve the Current Bucketing Parameters
3837
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3938

4039
To retrieve current collection values, use the
@@ -44,9 +43,8 @@ To retrieve current collection values, use the
4443

4544
db.runCommand( { listCollections: 1 } )
4645

47-
The result document contains a document for the time series collection
48-
which contains ``options.timeseries.granularity``,
49-
``options.timeseries.bucketMaxSpanSeconds``, and ``options.timeseries.bucketRoundingSeconds`` fields, if present.
46+
For time series collections, the output contains
47+
``granularity``, ``bucketMaxSpanSeconds``, and ``bucketRoundingSeconds`` fields, if present.
5048

5149
.. code-block:: javascript
5250
:copyable: false
@@ -77,8 +75,8 @@ which contains ``options.timeseries.granularity``,
7775
}
7876

7977

80-
Using a Single ``granularity`` Field
81-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78+
Using the "granularity" Field
79+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8280

8381
The following table shows the maximum time interval included in one
8482
bucket of data when using a given ``granularity`` value:
@@ -121,13 +119,18 @@ might contain only a single document.
121119
Using Custom Bucketing Parameters
122120
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123121

124-
Instead of ``granularity``, you can set bucket boundaries manually using
125-
the two custom bucketing parameters. Set both parameters to the
126-
same value, and do not set ``granularity``:
122+
In MongoDB 6.3 and higher, instead of ``granularity``, you can set
123+
bucket boundaries manually using the two custom bucketing parameters.
124+
Consider this approach if you need the additional precision to optimize
125+
a high volume of queries and :dbcommand:`insert` operations.
127126

128-
- ``bucketMaxSpanSeconds``, sets the maximum time between timestamps
127+
To use custom bucketing parameters, set both parameters to the same
128+
value, and do not set ``granularity``:
129+
130+
- ``bucketMaxSpanSeconds`` sets the maximum time between timestamps
129131
in the same bucket. Possible values are 1-31536000.
130-
- ``bucketRoundingSeconds``, the time interval that determines the
132+
133+
- ``bucketRoundingSeconds`` sets the time interval that determines the
131134
starting timestamp for a new bucket. When a document requires a new
132135
bucket, MongoDB rounds down the document's timestamp value by this
133136
interval to set the minimum time for the bucket.
@@ -160,11 +163,6 @@ Change Time Series Granularity
160163
You can increase ``timeseries.granularity`` from a shorter unit of time
161164
to a longer one using a :dbcommand:`collMod` command.
162165

163-
.. note::
164-
165-
To modify the granularity of a **sharded** time series collection,
166-
you must be running MongoDB 6.0 or later.
167-
168166
.. code-block:: javascript
169167

170168
db.runCommand({
@@ -187,4 +185,10 @@ command and set them to the same value:
187185
}
188186
})
189187

190-
You cannot decrease the granularity interval or the custom bucketing values.
188+
You cannot decrease the granularity interval or the custom bucketing
189+
values.
190+
191+
.. note::
192+
193+
To modify the granularity of a **sharded** time series collection,
194+
you must be running MongoDB 6.0 or later.

source/core/timeseries/timeseries-limitations.txt

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,13 @@ parameters later.
150150

151151
.. _timeseries-limitations-granularity:
152152

153-
Modification of ``granularity``
154-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155-
156-
After you set the ``granularity``, you can only increase it one level at
157-
a time. The ``granularity`` can change from ``"seconds"`` to
158-
``"minutes"`` or from ``"minutes"`` to ``"hours"``. Other changes are
159-
not allowed.
160-
161-
To change the ``granularity`` from ``"seconds"`` to ``"hours"``, first
162-
increase the ``granularity`` to ``"minutes"`` and then to ``"hours"``.
163-
164-
Modification of Bucket Parameters
165-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153+
Modifying Bucket Parameters
154+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
166155

167-
Once you set a collection's ``bucketMaxSpanSeconds`` and
168-
``bucketRoundingSeconds`` parameters, they can only be increased. Use
169-
the :dbcommand:`collMod` command to modify the ``bucketMaxSpanSeconds``
170-
and ``bucketRoundingSeconds`` parameters. For example:
156+
Once you set a collection's ``granularity`` or custom bucketing
157+
parameters ``bucketMaxSpanSeconds`` and ``bucketRoundingSeconds``, you
158+
can increase them, but not decrease them.
159+
Use the :dbcommand:`collMod` command to modify the parameters. For example:
171160

172161
.. code-block:: javascript
173162

@@ -178,8 +167,9 @@ and ``bucketRoundingSeconds`` parameters. For example:
178167

179168
.. note::
180169

181-
The ``bucketMaxSpanSeconds`` and ``bucketRoundingSeconds`` parameters must be
182-
equal. If you modify one parameter, you must also modify the other.
170+
``bucketMaxSpanSeconds`` and ``bucketRoundingSeconds`` must be
171+
equal. If you modify one parameter, you must also set the other to
172+
the same value.
183173

184174
.. _time-series-limitations-sharding:
185175

0 commit comments

Comments
 (0)