Efficiently saving arrays of objects with the same shape (same fields)

Hi. I want to save drone telemetry data from different drones to a mongoDB database. Each drone generates 20 telemetry messages per second, so this results in a huge number of messages for each drone mission.

This is a simplified version of the structure of the telemetry messages (all messages have the same structure):

{
timestamp: int64,
latitude: float64,
longitude: float64,
altitude: float32,
roll: float32,
pitch: float32,
yaw: float32,
velocity(X,Y,Z): float32,
acceleration(X,Y,Z): float32,
}

My first idea was to create a collection of missions, and inside each mission have a array field to store the telemetry messages received from the drones, but since mongo uses BSON, I feared this would mean that each field name would be repeated for each object. That would result in a huge overhead.

Therefore, I thought of splitting each field from the telemetry message to its own array, something like:

{
missionID: xxx,
droneID: xxx,
timestamps: [...],
latitudes: [...],
...
}

That is not very convenient, so maybe mongoDB has another way to solve this. I would assume this is a pretty common problem when having structured data. I know the advantage of mongoDB is to be able to store unstructured data but still, it would be nice to be able to provide some structure when it is possible.

What would you recommend for this application?

Thanks in advance

Hi @Jonathan_Pichel, welcome to the community!

You have two possible solutions for your case. The first is to use a Time Series collection. The second is to use the Bucket Pattern, which is implemented automatically by the time series collection under the hood.

Hi Artur, thanks!

Does the time series collection solve the repeated key names problem?

Yes, just don’t forget/jump the read of the documentation so you can configure it in the best way possible for your application.