Fastest way to get histogram of array sizes using MongoDB aggregation framework
问题 I'm trying to get a list of the number of records that have arrays of varying size. I want to get the distribution of array sizes for all records so I can build a histogram like this: | * | * documents | * * | * * * |_*__*__*___*__*___ 2 5 6 23 47 Array Size So the raw documents look something like this: {hubs : [{stuff:0, id:6}, {stuff:1"}, .... ]} {hubs : [{stuff:0, id:6}]}` So far using the aggregation framework and some of the help here I've come up with db.sitedata.aggregate([{ $unwind:'