MongoDB Document Growth and Storage

Track changes in average document size and storage ratios. Detect schema growth effects on cache, disk, and network early.

2026-09-19 · 2 min read

Why this problem matters

Growing documents can increase disk use, cache working set, and network transfer. Unbounded arrays or embedded history can also approach the document-size limit.

How to diagnose it

Track avgObjSize, size, storageSize, and document-count trends through collStats. Validate schema changes and fast-growing fields with sampled, privacy-conscious analysis.

scale only changes the reported size unit. The command does not modify documents or collection storage.

const s = db.runCommand({collStats: "orders", scale: 1048576});
({count: s.count, avgObjSizeBytes: s.avgObjSize, sizeMB: s.size, storageSizeMB: s.storageSize})

A safe solution approach

Bound unbounded data with a separate collection, bucket, or archival design. Test schema changes alongside query and atomicity requirements.

Why continuous monitoring matters

Continuous size monitoring exposes gradual schema inflation before an abrupt disk alert. moon monitors with low overhead and routes Slack, PagerDuty, or webhook alerts.

Frequently asked questions

Is rising avgObjSize inherently bad?

No, growth may be expected from business requirements. Evaluate disk, cache, network, and document-limit implications together.

How does moon help with this problem?

moon continuously observes SQL Server, PostgreSQL, and MongoDB signals, helping teams evaluate the problem as a trend instead of relying on a one-time check.