If you need to know collection size breakdown and information on index usage, you basically need these two:
-
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” }))
-
db.events.aggregate([{ $indexStats: {} }])- Show usage information per index