-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Time series updates for sharding support and updates / deletes #6085
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
Changes from all commits
aa63be8
6aa1b85
0778f0c
9ed1574
b8695ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
MongoDB 5.1 provides support for sharded :ref:`time series collections | ||
<manual-timeseries-collection>`. | ||
|
||
See: | ||
|
||
- :dbcommand:`shardCollection` | ||
- :ref:`Time Series Limitations <time-series-limitations-sharding>` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Optional. Possible values are: | ||
|
||
- ``"seconds"`` | ||
- ``"minutes"`` | ||
- ``"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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as existing copy; shouldn't need review. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Optional. The name of the field which contains metadata in each | ||
time series document. The metadata in the specified field should | ||
be data that is used to label a unique series of documents. The | ||
metadata should rarely, if ever, change. | ||
|
||
The name of the specified field may not be ``_id`` or the same as | ||
the ``timeseries.timeField``. The field can be of any type. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as existing copy; shouldn't need review. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Required. The name of the field which contains the date in each | ||
time series document. Documents in a time series collection must | ||
have a valid BSON date as the value for the ``timeField``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as existing copy; shouldn't need review. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _find-and-modify: | ||
|
||
============= | ||
findAndModify | ||
============= | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,8 @@ Definition | |
unique: <boolean>, | ||
numInitialChunks: <integer>, | ||
presplitHashedZones: <boolean>, | ||
collation: { locale: "simple" } | ||
collation: { locale: "simple" }, | ||
timeseries: <object> | ||
} | ||
|
||
:dbcommand:`shardCollection` has the following fields: | ||
|
@@ -170,6 +171,64 @@ Definition | |
|
||
.. versionadded:: 4.4 | ||
|
||
* - :ref:`timeseries <cmd-shard-collection-timeseries>` | ||
|
||
- object | ||
|
||
- .. _cmd-shard-collection-timeseries: | ||
|
||
Optional. Specify this option to create a new sharded | ||
:ref:`time series collection <manual-timeseries-collection>`. | ||
|
||
To shard an existing time series collection, omit this | ||
parameter. When you omit this parameter and specify a time | ||
series collection in the ``shardCollection`` parameter, | ||
MongoDB automatically uses the values from the time series | ||
collection as the values for the ``timeseries`` field. | ||
|
||
For detailed syntax, see | ||
:ref:`sharded-time-series-collection-options`. | ||
|
||
.. versionadded:: 5.1 | ||
|
||
.. _sharded-time-series-collection-options: | ||
|
||
Time Series Options | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 5.1 | ||
|
||
Specify the :ref:`timeseries <cmd-shard-collection-timeseries>` option | ||
to :dbcommand:`shardCollection` to create a new sharded | ||
:ref:`time series collection <manual-timeseries-collection>`. | ||
|
||
The :ref:`timeseries <cmd-shard-collection-timeseries>` option takes | ||
the following fields: | ||
|
||
.. list-table:: | ||
:header-rows: 1 | ||
:widths: 20 20 80 | ||
|
||
* - Field | ||
- Type | ||
- Description | ||
|
||
* - ``timeField`` | ||
- string | ||
- .. include:: /includes/time-series/fact-time-field-description.rst | ||
|
||
* - ``metaField`` | ||
- string | ||
- .. include:: /includes/time-series/fact-meta-field-description.rst | ||
|
||
* - ``granularity`` | ||
- string | ||
- .. include:: /includes/time-series/fact-granularity-description.rst | ||
|
||
* - ``bucketMaxSpanSeconds`` | ||
- integer | ||
- Optional. The maximum range of time values for a bucket, | ||
in seconds. | ||
|
||
Considerations | ||
-------------- | ||
|
@@ -194,6 +253,21 @@ avoid scalability and perfomance issues. | |
- :ref:`sharding-shard-key-selection` | ||
- :ref:`sharding-shard-key` | ||
|
||
Shard Keys on Time Series Collections | ||
````````````````````````````````````` | ||
|
||
When sharding time series collections, you can only specify the | ||
``metaField`` (or sub-fields of ``metaField``), ``timeField``, or both | ||
in the shard key. No other fields, including ``_id``, are allowed in the | ||
shard key pattern. | ||
|
||
- ``metaField`` can be either a :ref:`hashed shard key | ||
<sharding-hashed-sharding>` or a :ref:`ranged shard key | ||
<sharding-ranged>`. | ||
|
||
- ``timeField`` can only be a :ref:`ranged shard key | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
<sharding-ranged>` and must be at the end of the shard key pattern. | ||
|
||
.. _hashed-shard-keys: | ||
|
||
Hashed Shard Keys | ||
|
@@ -274,6 +348,7 @@ in the ``records`` database and uses the ``zipcode`` field as the | |
.. code-block:: javascript | ||
|
||
db.adminCommand( { shardCollection: "records.people", key: { zipcode: 1 } } ) | ||
|
||
|
||
.. seealso:: | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _collection-method: | ||
|
||
================== | ||
Collection Methods | ||
================== | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add more details here. Some of the key things to highlight would be,
shardCollection
command, which now acceptstimeseries
parameter.metaField
and/ortimeField
in the shard key). Details here: https://docs.google.com/document/d/1ljVx7gni5dg6vuLSL2li14lq13T2RqENWEGKKeliCzw/edit#heading=h.1qvrx81umcnx