Hi @Javier_Blanco ,
the suggestions presented by @NeNaD and @steevej does not meant to eliminate the devices collection but to add needed information to sensorsDataHistoric
to allow a query to be based just by it, in your case this “group.id” .
We call this the extended reference pattern when you embed additional reference keys to avoid lookups and joins to speedup queries:
Ty