[SERVER-54640] Support a compound index on a single metadata field followed by the time field in a time-series collection Created: 19/Feb/21  Updated: 29/Oct/23  Resolved: 25/Feb/21

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Task Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
Duplicate
is duplicated by SERVER-54641 Support a compound indexes on multipl... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2021-03-08
Participants:

 Description   

If the index requested is a compound index with both the metadata and the time fields:

 {
    createIndexes: 'abc',

    indexes: [{ 'mm.tag1': 1, time: 1 }]

}

The index specification created on the bucket collection will be:

 
{
    createIndexes: 'system.buckets.abc',

    indexes: [{'meta.tag1': 1, 'control.min.time': 1, 'control.max.time': 1}]
}

Since buckets in the underlying bucket collection may contain overlapping time ranges, we include both lower and upper bounds in the index to support the query optimizer's ability to order measurements.

Conversely if the time field has to be indexed in descending order, we would transform a compound index:

{
    createIndexes: 'abc',
    indexes: [{ 'mm.tag1': 1, time: -1 }]

}

as follows:

{
    createIndexes: 'system.buckets.abc',

    indexes: [{'meta.tag1': 1, 'control.max.time': -1, 'control.min.time': -1}]

}



 Comments   
Comment by Githook User [ 25/Feb/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-54640 support creating an index on the time field in a time-series collection
Branch: master
https://github.com/mongodb/mongo/commit/d00804e7529269d0c2e0dbea1b5544c0456ef9b4

Generated at Thu Feb 08 05:34:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.