在 MongoDB 中计数文档使用 countDocuments() 方法获取准确的过滤后计数,以及使用 estimatedDocument() 获取快速近似总数。countDocuments() 支持查询过滤器并提供精确结果,但在大型集合上可能较慢。estimatedDocumentCount() 使用集合元数据进行快速估算,非常适合仪表板指标和快速统计。
countDocuments()
estimatedDocument()
estimatedDocumentCount()
用自己的话写下这一站的结论。