Reputation: 4815
I am looking to use MongoDB to store time-series data. For sake of discussion imagine I have a finite numbers of sensors deployed (e.g. 10-100-1000 sensors). Each sensors has a dozen of "metrics" (e.g. temp, humidity, etc) which are collected every minute and then stored. There is a front end which then displays charts for each sensors or aggregate on selected intervals.
What is the best approach, performance wise, to store this? Specifically:
Thanks a lot
Upvotes: 3
Views: 455
Reputation: 4425
Approach 1(A): Creating a single database for everything. (With single collection)
Pros:
Cons:
Approach 1(B): Creating a single database for everything. (With 1 collection for each sensor)
Pros:
Cons:
Performance-wise, does it matters if I partition the data by each sensor or by metrics?
Performance-wise, should i make a collection just for the sensors info and then collections for data or just merge the two in the same collection?
Creating a collection for sensor metadata and sensor data may be needful. It will minimize duplicating sensor metadata in each and every collected sensor data.
You may like to read Williams blog post here on designing this pattern.
As always, it's better to design a sample schema and test your queries within your test environment.
Upvotes: 4