The six patterns, worked in detail
coreadvancedSubset keeps only a needed slice of a large sub-document embedded. Bucket groups many small readings into fewer per-interval documents. Extended reference copies a few fields to skip a $lookup. Computed stores a value instead of recalculating it. Attribute turns sparse fields into a queryable array. Outlier handles the rare oversized document separately.
Think of it as
Each pattern targets exactly one measurable cost: subset targets working-set size, bucket targets per-document overhead at high write volume, extended reference targets join count, computed targets read-time CPU, attribute targets index count on sparse fields, and outlier targets the one document that would otherwise force a worse design for every other document.
What we're doing: Work through the bucket pattern end to end: the problem it solves and the resulting document shape.
- 2
- One document per reading means one index entry, one document header, and one write per reading — overhead that adds up at high ingestion rates.
- 6
- Bucketing by hour cuts document count by roughly the average readings-per-bucket, trading a slightly more complex write for far less per-document overhead and often better query locality for "this sensor, this hour" reads.
Why this works: The bucket pattern is not just "batch writes" — it deliberately reshapes the schema around a natural grouping key (sensor + time interval) so both writes and the most common read (a time range for one sensor) land on a small number of documents instead of scanning many.
Picking a bucket interval without checking the read pattern it needs to serve
Wrong
Better
What you see: A query for "the last hour" has to open and scan a bucket document containing an entire day of readings, most of them irrelevant to the query.
Why: The bucket size is itself a schema decision driven by access patterns, the same principle underlying every other pattern here — an interval mismatched to the dominant query range reintroduces the per-read overhead bucketing was meant to remove.
- measured symptom — e.g. slow read, huge working set
- matching pattern — one of the six
- targeted fix — not a general rewrite
Pattern → symptom it targets → what changes
Together
Remember: Subset, bucket, extended reference, computed, attribute, outlier — six patterns, each targeting one specific, measurable symptom. Apply one at a time, against a measured cost, not speculatively.
See also: schema design patterns overview · time series bucketing

