mongoDB 统计去重后的count,用$group实现 db.collection.aggregate([ { $group: { _id: '$myData'}}, { $count: 'myCount'} ], { maxTimeMS: 60000, // aggregate 超时时间,数据量大时需设置大些 allowDiskUse: true, // 数据量大时需启用