Home > front end >  How better to design MongoDB for multi time serias data
How better to design MongoDB for multi time serias data

Time:11-17

I have a time series data, for example myData, and display it to my ui, it could be Day, Week, Month, Year.

How it's better to store in MongoDB, should I create separate Collections for this like: myDataDay myDataWeek ...

or it's better to store it in one Collections with Day, Week, Month, Year keys?

How could it impact the performance?

CodePudding user response:

You will need to answer following questions:

  1. Number and type of paralel queries you send to the database?
  2. Are there other fields that data will be searched on?
  3. Are the 90% of all queries in the range of last year/month/date/hour or other?

If you split the data between many collections logic on app side will become more complex , from the other hand if you keep everything in same collection at some point in time your database will become bigger and more difficult to mantain...

You may take a look to the special collection types dedicated to time series data , but in general it very depends on the amount of data and and distribution you expect ...

  • Related