2 / 3
May 2024

Hi,

We’ve been working with MongoDB for more than a decade and we are now considering the use of MongoDB Time Series. We do have time-series data: every document has its corresponding timestamp, there is a new record inserted every minute, and there is no need to modify data already inserted.

However, the data we are planning to save associated to each timestamp is somewhat complex and actually already pre-processed.

Our use case is related to finance, but below you can find a simplified document illustrating a similar example with cars and motorbikes in a parking lot.

{ timestamp: ISODate("2024-04-23T00:00:00.000Z"), metadata: { parking_id: 'XXX', parking_type: 'INDOOR|OUTDOOR' }, active_parkings: 4023, cars:{ total_cars: 4444 variation: 25 number_cars_suv: 421 number_cars_sportive: 321 variation_number_cars_suv: 33 }, motorbikes:{ total:422 scooters: 215 } }

Our application is already calculating the totals accumulated and the variations between consecutive timestamps before inserting the documents. When the data is read, there is no processing to be done over the data; it just needs to read about 200-500 documents (consecutive timestamps).

The question is: Is TimeSeries a good fit for this use case, or would “normal” MongoDB collections work the same well?

Thanks!

Hello Miguel,

Thanks for reaching out. I work with the time-series product team here at MongoDB. From an initial look, your use-case sounds like a good fit for time-series collections. Here are some reasons why:

a. You mentioned there’s no need to modify the data already inserted for your use-case. TSCs are built exactly for such append-only use-cases where we offer other optimizations in tradeoff for updates and deletes.
b. Query optimizations - Given your data model and finance use-case, it’s likely your query patterns leverage range and meta-field based filtering and querying. TSCs are natively designed to optimize on these kinds of queries, which might not be as straightforward to achieve with regular collections.
c. TSCs also take advantage of the nature of time-series data with data collocation and columnar storage format. This means that it allows for more effective compression algorithms. Your time-series data can expect significant storage reduction compared to regular collections, even if your data is already pre-processed.
d. We also designed TSCs to make it easier to work with time-stamped data. So you have access to native temporal functionalities like date-time truncation, densification, gap filling features etc, which can save your development cost.

Happy to clarify further about time-series and learn more about your use-case . You can also check out our page here – MongoDB Time Series | MongoDB to learn more.


Nishith