Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers MongoDB schema design patterns and anti-patterns, including embed-vs-reference decisions, unbounded arrays, and schema validation.
70% 87%+17 ptsof test cases passed
Passed 20 of 23 test cases with the skill, and 16 of 23 without it.
3 of 3 safety checks passed
16 agent runs
Collection count alone is not the anti-pattern. The anti-pattern is using collections as a substitute for indexes — creating one collection per category, time period, or partition key instead of indexing a single collection. Every collection carries a default _id index that consumes storage and strains the replica set, and cross-collection queries require $lookup or $unionWith, adding complexity and overhead.
Incorrect (one collection per day as partitioning strategy):
Creating one collection per time period (e.g. temperatures_2024_05_10, temperatures_2024_05_11, …) means each collection carries its own default _id index (365 collections/year = 365 extra indexes), cross-day queries require $unionWith across many collections, schema validation / indexes / TTL must be duplicated on every collection, and application code must dynamically resolve the collection name for each query.
Correct (single collection with an index):
// All readings in one collection — the index does the partitioning work
{ _id: ObjectId(), timestamp: ISODate("2024-05-10T10:00:00Z"), temperature: 60 }
{ _id: ObjectId(), timestamp: ISODate("2024-05-10T11:00:00Z"), temperature: 61 }
{ _id: ObjectId(), timestamp: ISODate("2024-05-11T10:00:00Z"), temperature: 68 }
db.temperatures.createIndex({ timestamp: 1 })
// Efficient range query — one collection, one index
db.temperatures.find({
timestamp: { $gte: ISODate("2024-05-10"), $lt: ISODate("2024-05-11") }
})
// Optional TTL for automatic expiry (e.g. 90 days)
db.temperatures.createIndex({ timestamp: 1 }, { expireAfterSeconds: 7776000 })
Even better (bucket pattern or time series collection):
For high-volume time-stamped data, group readings into buckets or use a native time series collection, which is optimized for this workload:
// Bucket pattern — one document per day
Published skills whose descriptions closely match this one, with their benchmark result.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.