Skip to content

Commit 734f72c

Browse files
DOCS-15516 Time series range outside 1970-2038 behavior (#2119)
1 parent e409e60 commit 734f72c

File tree

4 files changed

+63
-23
lines changed

4 files changed

+63
-23
lines changed

source/core/timeseries-collections.txt

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,37 @@ When you query time series collections, you operate on one document per
102102
measurement. Queries on time series collections take advantage of the
103103
optimized internal storage format and return results faster.
104104

105+
.. tip::
106+
107+
To improve query performance, you can manually :ref:`add secondary
108+
indexes <timeseries-add-secondary-index>` on measurement fields or
109+
any field in your time series collection.
110+
105111
.. important:: Backward-Incompatible Feature
106112

107113
.. include:: /includes/downgrade-for-timeseries-collections.rst
108114

115+
.. _manual-timeseries-internal-index:
116+
109117
Internal Index
110118
``````````````
111119

112120
When you create a time series collection, MongoDB automatically creates
113121
an internal :ref:`clustered index <clustered-collections>` on the time
114-
field. The internal index provides several performance benefits
115-
including improved query efficiency and reduced disk usage. To learn
116-
more about the performance benefits of clustered indexes, see
117-
:ref:`Clustered Collections <clustered-collections>`.
118-
119-
The internal index for a time series collection is not displayed by
120-
:dbcommand:`listIndexes`.
121-
122-
.. tip::
123-
124-
To improve query performance, you can manually :ref:`add secondary
125-
indexes <timeseries-add-secondary-index>` on measurement fields or
126-
any field in your time series collection.
122+
field. This index improves query efficiency and reduces disk
123+
usage. To learn more about the performance benefits of clustered
124+
indexes, see :ref:`Clustered Collections <clustered-collections>`.
125+
126+
The internal index is not listed when you run :dbcommand:`listIndexes`.
127+
128+
.. note::
129+
If you insert a document into a collection with a ``timeField``
130+
value before ``1970-01-01T00:00:00.000Z`` or after
131+
``2038-01-19T03:14:07.000Z``,
132+
MongoDB logs a warning and prevents some query optimizations from
133+
using the internal index. :ref:`Create a secondary index <timeseries-add-secondary-index>`
134+
on the ``timeField`` to regain query performance and resolve the log
135+
warning.
127136

128137
Get Started
129138
-----------

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,13 @@ Round Numeric Data to Few Decimal Places
205205
Round numeric data to the precision required for your application.
206206
Rounding numeric data to fewer decimal places improves the compression
207207
ratio.
208+
209+
.. _tsc-best-practice-optimize-query-performance:
210+
211+
Optimize Query Performance
212+
--------------------------
213+
214+
To improve query performance,
215+
:ref:`create one or more secondary indexes <timeseries-add-secondary-index>`
216+
on your ``timeField`` and ``metaField`` to support common query
217+
patterns.

source/core/timeseries/timeseries-migrate-data-into-timeseries-collection.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,23 @@ The command returns the following output:
240240
:binary:`~bin.mongorestore` cannot create indexes on time series
241241
collections.
242242

243-
If your original collection had secondary indexes, manually recreate them
244-
now.
243+
If your original collection had secondary indexes, manually recreate
244+
them now. If your collection includes ``timeField`` values before
245+
``1970-01-01T00:00:00.000Z`` or after ``2038-01-19T03:14:07.000Z``,
246+
MongoDB logs a warning and disables some query optimizations that make
247+
use of the :ref:`internal clustered index <manual-timeseries-internal-index>`. :ref:`Create a secondary index
248+
<timeseries-add-secondary-index>` on the ``timeField`` to regain query
249+
performance and resolve the log warning.
245250

246251
.. seealso::
247252

248253
:ref:`timeseries-add-secondary-index`
254+
255+
256+
If you insert a document into a collection with a ``timeField``
257+
value before ``1970-01-01T00:00:00.000Z`` or after
258+
``2038-01-19T03:14:07.000Z``,
259+
MongoDB logs a warning and prevents some query optimizations from
260+
using the internal index. :ref:`Create a secondary index <timeseries-add-secondary-index>`
261+
on the ``timeField`` to regain query performance and resolve the log
262+
warning.

source/core/timeseries/timeseries-secondary-index.txt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,21 @@ measurements from weather sensors:
113113
]
114114
)
115115

116-
Time Series collections automatically create a clustered index. The
117-
clustered index may automatically be used by the query planner to
118-
improve sort performance in some situations. For more information on
119-
clustered indexes, see :ref:`clustered index
120-
<db.createCollection.clusteredIndex>`.
121-
122-
The following sort operation on the timestamp field uses the clustered
123-
index to improve performance:
116+
Time Series collections :ref:automatically create an internal
117+
:ref:`clustered index <db.createCollection.clusteredIndex>`. The query
118+
planner uses this index to improve sort performance.
119+
120+
.. note::
121+
If you insert a document into a collection with a ``timeField``
122+
value before ``1970-01-01T00:00:00.000Z`` or after
123+
``2038-01-19T03:14:07.000Z``,
124+
MongoDB logs a warning and prevents some query optimizations from
125+
using the internal index. :ref:`Create a secondary index <timeseries-add-secondary-index>`
126+
on the ``timeField`` to regain query performance and resolve the log
127+
warning.
128+
129+
The following sort operation on the ``timestamp`` field uses the
130+
clustered index to improve performance:
124131

125132
.. code-block:: javascript
126133

0 commit comments

Comments
 (0)