@@ -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
2322into buckets. By setting granularity, you control how
2423frequently 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
4039To 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
8381The following table shows the maximum time interval included in one
8482bucket of data when using a given ``granularity`` value:
@@ -121,13 +119,18 @@ might contain only a single document.
121119Using 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
160163You can increase ``timeseries.granularity`` from a shorter unit of time
161164to 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.
0 commit comments