What I understood is $bucket is useful when embedding 1:S (squillion) relationship exist between two entities or 1:M but document size is much more. Bucketing also help to improve performance of referring specific buckets only.
When is it preferred to use $bucket or $bucketauto or $facet?
For example, there is an application, which add following sensor records at every 5 minutes:
{sensor_id : <> , sensor_name:< >, location : <>, timestamp : <>, value:<>}
OR
{sensor_id : <> , sensor_name:< >, location : <>,reading:[{timestamp : <>, value:<>},…]}
But to create a bucket schema also, such large collection need to be queried. And Insertion of Sensor data is continuous . So, existing bucket schema need to be updated frequently. It shows two drawbacks : i) duplication of data in Denormalized and bucket format both. ii) Overhead of updating bucket schema and that too on continuously increasing collection.
Can you explain how and when to use bucket in such situation?