Skip to content

Commit 6c700e6

Browse files
updates per Arun's feedback
1 parent 0778f0c commit 6c700e6

File tree

7 files changed

+125
-32
lines changed

7 files changed

+125
-32
lines changed

source/core/timeseries-collections.txt

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,44 +97,19 @@ When creating a time series collection, specify the following options:
9797

9898
- string
9999

100-
- Required. The name of the field which contains the date in each
101-
time series document. Documents in a time series collection must
102-
have a valid BSON date as the value for the ``timeField``.
100+
- .. include:: /includes/time-series/fact-time-field-description.rst
103101

104102
* - ``timeseries.metaField``
105103

106104
- string
107105

108-
- Optional. The name of the field which contains metadata in each
109-
time series document. The metadata in the specified field should
110-
be data that is used to label a unique series of documents. The
111-
metadata should rarely, if ever, change.
112-
113-
The name of the specified field may not be ``_id`` or the same as
114-
the ``timeseries.timeField``. The field can be of any type.
106+
- .. include:: /includes/time-series/fact-meta-field-description.rst
115107

116108
* - ``timeseries.granularity``
117109

118110
- string
119111

120-
- Optional. Possible values are ``"seconds"``, ``"minutes"``, and
121-
``"hours"``. By default, MongoDB sets the ``granularity`` to
122-
``"seconds"`` for high-frequency ingestion.
123-
124-
Manually set the ``granularity`` parameter to improve performance
125-
by optimizing how data in the time series collection is stored
126-
internally. To select a value for ``granularity``, choose the
127-
closest match to the time span between consecutive incoming
128-
measurements.
129-
130-
If you specify the ``timeseries.metaField``, consider the time
131-
span between consecutive incoming measurements that have the same
132-
unique value for the ``metaField`` field. Measurements often have
133-
the same unique value for the ``metaField`` field if they come
134-
from the same source.
135-
136-
If you do not specify ``timeseries.metaField``, consider the time
137-
span between all measurements that are inserted in the collection.
112+
- .. include:: /includes/time-series/fact-granularity-description.rst
138113

139114
* - ``expireAfterSeconds``
140115

source/core/timeseries/timeseries-limitations.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,15 @@ Sharding
132132
~~~~~~~~
133133

134134
Starting in MongoDB 5.1, sharded time series collections are supported.
135+
When using sharded time series collections, you cannot:
135136

136-
You cannot modify the ``granularity`` of a sharded time series collection.
137+
- Modify the ``granularity`` of a sharded time series
138+
collection.
139+
140+
- Run sharding administration commands, including:
141+
142+
- :dbcommand:`moveChunk`
143+
- :dbcommand:`splitChunk`
137144

138145
Aggregation $out and $merge
139146
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
MongoDB 5.1 provides support for sharded :ref:`time series collections
2-
<manual-timeseries-collection>`. See :ref:`Time Series Limitations
3-
<time-series-limitations-sharding>`.
2+
<manual-timeseries-collection>`.
3+
4+
See:
5+
6+
- :dbcommand:`shardCollection`
7+
- :ref:`Time Series Limitations <time-series-limitations-sharding>`
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Optional. Possible values are:
2+
3+
- ``"seconds"``
4+
- ``"minutes"``
5+
- ``"hours"``
6+
7+
By default, MongoDB sets the ``granularity`` to ``"seconds"`` for
8+
high-frequency ingestion.
9+
10+
Manually set the ``granularity`` parameter to improve performance
11+
by optimizing how data in the time series collection is stored
12+
internally. To select a value for ``granularity``, choose the
13+
closest match to the time span between consecutive incoming
14+
measurements.
15+
16+
If you specify the ``timeseries.metaField``, consider the time
17+
span between consecutive incoming measurements that have the same
18+
unique value for the ``metaField`` field. Measurements often have
19+
the same unique value for the ``metaField`` field if they come
20+
from the same source.
21+
22+
If you do not specify ``timeseries.metaField``, consider the time
23+
span between all measurements that are inserted in the collection.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Optional. The name of the field which contains metadata in each
2+
time series document. The metadata in the specified field should
3+
be data that is used to label a unique series of documents. The
4+
metadata should rarely, if ever, change.
5+
6+
The name of the specified field may not be ``_id`` or the same as
7+
the ``timeseries.timeField``. The field can be of any type.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Required. The name of the field which contains the date in each
2+
time series document. Documents in a time series collection must
3+
have a valid BSON date as the value for the ``timeField``.

source/reference/command/shardCollection.txt

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Definition
3535
unique: <boolean>,
3636
numInitialChunks: <integer>,
3737
presplitHashedZones: <boolean>,
38-
collation: { locale: "simple" }
38+
collation: { locale: "simple" },
39+
timeseries: <object>
3940
}
4041

4142
:dbcommand:`shardCollection` has the following fields:
@@ -170,6 +171,64 @@ Definition
170171

171172
.. versionadded:: 4.4
172173

174+
* - :ref:`timeseries <cmd-shard-collection-timeseries>`
175+
176+
- object
177+
178+
- .. _cmd-shard-collection-presplitHashedZones:
179+
180+
Optional. Specify this option to create a new sharded
181+
:ref:`time series collection <manual-timeseries-collection>`.
182+
183+
To shard an existing time series collection, omit this
184+
parameter. When you omit this parameter and specify a time
185+
series collection in the ``shardCollection`` parameter,
186+
MongoDB automatically uses the values from the time series
187+
collection as the values for the ``timeseries`` field.
188+
189+
For detailed syntax, see
190+
:ref:`sharded-time-series-collection-options`.
191+
192+
.. versionadded:: 5.1
193+
194+
.. _sharded-time-series-collection-options:
195+
196+
Time Series Options
197+
~~~~~~~~~~~~~~~~~~~
198+
199+
.. versionadded:: 5.1
200+
201+
Specify the :ref:`timeseries <cmd-shard-collection-timeseries>` option
202+
to :dbcommand:`shardCollection` to create a new sharded
203+
:ref:`time series collection <manual-timeseries-collection>`.
204+
205+
The :ref:`timeseries <cmd-shard-collection-timeseries>` option takes
206+
the following fields:
207+
208+
.. list-table::
209+
:header-rows: 1
210+
:widths: 20 20 80
211+
212+
* - Field
213+
- Type
214+
- Description
215+
216+
* - ``timeField``
217+
- string
218+
- .. include:: /includes/time-series/fact-time-field-description.rst
219+
220+
* - ``metaField``
221+
- string
222+
- .. include:: /includes/time-series/fact-meta-field-description.rst
223+
224+
* - ``granularity``
225+
- string
226+
- .. include:: /includes/time-series/fact-granularity-description.rst
227+
228+
* - ``bucketMaxSpanSeconds``
229+
- integer
230+
- Optional. The maximum range of time values for a bucket,
231+
in seconds.
173232

174233
Considerations
175234
--------------
@@ -194,6 +253,20 @@ avoid scalability and perfomance issues.
194253
- :ref:`sharding-shard-key-selection`
195254
- :ref:`sharding-shard-key`
196255

256+
Shard Keys on Time Series Collections
257+
`````````````````````````````````````
258+
259+
When sharding time series collections, you can only specify the
260+
``metaField``, ``timeField``, or both in the shard key. No other fields,
261+
including ``_id``, are allowed in the shard key pattern.
262+
263+
- ``metaField`` can be either a :ref:`hashed shard key
264+
<sharding-hashed-sharding>` or a :ref:`ranged shard key
265+
<sharding-ranged>`.
266+
267+
- ``timeField`` can only be a :ref:`ranged shard key
268+
<sharding-ranged>`.
269+
197270
.. _hashed-shard-keys:
198271

199272
Hashed Shard Keys
@@ -274,6 +347,7 @@ in the ``records`` database and uses the ``zipcode`` field as the
274347
.. code-block:: javascript
275348

276349
db.adminCommand( { shardCollection: "records.people", key: { zipcode: 1 } } )
350+
277351

278352
.. seealso::
279353

0 commit comments

Comments
 (0)