Skip to content

Clarify granularity #5532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions source/core/timeseries-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,24 @@ When creating a time series collection, specify the following options:

- string

- Optional. Possible values are ``"seconds"`` (default),
``"minutes"``, and ``"hours"``. Set the granularity to the value
that is the closest match to the time span between consecutive
incoming measurements. Setting the ``granularity`` parameter
accurately improves performance by optimizing how data in the time
series collection is stored internally.
- Optional. Possible values are ``"seconds"``, ``"minutes"``, and
``"hours"``. By default, MongoDB sets the ``granularity`` to
``"seconds"`` for high-frequency ingestion.

Manually set the ``granularity`` parameter to improve performance
by optimizing how data in the time series collection is stored
internally. To select a value for ``granularity``, choose the
closest match to the time span between consecutive incoming
measurements.

If you specify the ``timeseries.metaField``, consider the time
span between consecutive incoming measurements that have the same
unique value for the ``metaField`` field. Measurements often have
the same unique value for the ``metaField`` field if they come
from the same source.

If you do not specify ``timeseries.metaField``, consider the time
span between all measurements that are inserted in the collection.

* - ``expireAfterSeconds``

Expand Down
38 changes: 37 additions & 1 deletion source/core/timeseries/timeseries-granularity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Set Granularity for Time Series Data
When you create a :ref:`time series collection
<manual-timeseries-collection>`, set the granularity to the value that
is the closest match to the time span between consecutive incoming
measurements:
measurements that have the same unique value for the ``metaField``
field:

.. code-block:: javascript

Expand All @@ -44,6 +45,41 @@ measurements:
Setting the ``granularity`` parameter accurately improves performance by
optimizing how data in the time series collection is stored internally.

To set the parameter accurately, choose a ``granularity`` value that is
closest to the ingestion rate for a unique data source as specified by
the value for the ``metaField`` field.

For example, if your ``metaField`` data identifies weather sensors and
you ingest data from each individual sensor once every 5 minutes, you
should choose ``"minutes"``. Even if you have thousands of sensors and
the data coming in from different sensors is only seconds apart, the
``granularity`` should still be based on the ingestion rate for one
sensor that is uniquely identified by its metadata.

In the following table, you can see the max time span of data that is
stored together for each ``granularity`` value:

.. list-table::
:header-rows: 1
:widths: 40 60

* - ``granularity``

- Covered Time Span

* - ``"seconds"`` (default)

- one hour

* - ``"minutes"``

- 24 hours

* - ``"hours"``

- 30 days


.. seealso::

:ref:`Timing of Automatic Removal
Expand Down