skip to content
Alvin Lucillo

Showing coll and index stats

/ 1 min read

If you need to know collection size breakdown and information on index usage, you basically need these two:

  1. db.events.aggregate([{ $collStats: { storageStats: {}, count: {} } }])

    • Show storage size and its breakdown (e.g., index size, collection data size)
    • If you don’t want to use the aggregation, you can use the short form (db.events.stats()) or the deprecated one (db.runCommand({ collStats: “events” }))
  2. db.events.aggregate([{ $indexStats: {} }])

    • Show usage information per index