You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Amazon DocumentDB 5.0.0执行集合统计命令报错:不支持$collStats聚合阶段

解决DocumentDB 5.0执行db.collection.stats()报错及查看压缩率的方法

报错原因

DocumentDB 5.0对$collStats聚合阶段的支持存在限制,db.printCollectionStats()和db.collection.stats()底层依赖该阶段,但默认请求了不支持的字段,因此触发Aggregation stage not supported: '$collStats'错误。

查看压缩率的可行方案

方案1:使用显式聚合查询调用$collStats

直接指定storageStats字段执行聚合,规避不支持的参数:

// 将your_collection替换为目标集合名称
db.your_collection.aggregate([
  { $collStats: { storageStats: {} } }
])

返回结果中:

  • storageStats.size:集合未压缩的原始数据大小
  • storageStats.storageSize:压缩后实际占用的存储大小

压缩率计算公式:

压缩率 = (1 - storageSize / size) * 100

方案2:通过CloudWatch指标查看

利用AWS CloudWatch的DocumentDB专属指标计算:

  • CollectionDataSize:集合未压缩的数据大小
  • CollectionStorageSize:集合压缩后占用的存储大小
    同样使用上述公式计算压缩率,适合批量监控或无需连接数据库的场景。

内容的提问来源于stack exchange,提问作者mkb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 06:34:58