I need to store high frequency, periodic time-series data of some metrics in mongodb (after every 5 seconds), since the normal approach is too expensive:
{
timestamp: ISODate("2013-10-10T23:06:37.000Z"),
type: String,
value: Number
},
I want to write an optimized one as mentioned here, the document would look like:
{
timestamp_hour: ISODate("2013-10-10T23:06:00.000Z"),
type: “memory_used”,
values: {
0: 999999,
…
37: 1000000,
38: 1500000,
…
720: 2000000,
}
}
in the above model instead of storing a document every 5 seconds,I am storing a document every 1 hour and storing all the data generated in that particular hour in the "values" object as key value pair.
To keep the document size as minimum as possible and to increase the performance while fetching the data, should I use Array to store the values or dynamic object, which one will give me the smallest size and fastest read( I will be needing chunks of values to read in any specific document)?
and if I use the object, How to define the schema for it since the number of values( 720 in above example) is not constant it can be changed.