Lesson 4 of 14
Why document size limits exist - 006
16MB limit chala peddadi anukuntunnara? Oka unlimited array pedithe, okka roju lo 'Document Too Large' error chustaru.
Core Explanation: 16MB limit undi RAM efficiency kosam. Oka document ni read cheyyali ante, entire document RAM loki ravali. Pedda documents network bandwidth ni, RAM cache ni tinesthay. Main culprit: Unbounded Arrays (e.g., storing comments inside a post indefinitely).
Wrong Practice: Embedding unbounded arrays.
{
"_id": "post1",
"comments": [ ...10000 objects... ] // Dangerous!
}
Best Practice: Bucket pattern or referencing limits overflow.
// Use subset pattern for preview, reference collection for full list
{
"_id": "post1",
"recentComments": [ ...last 5... ]
}
// Store rest in 'comments' collection
Closing Insight: "Design time lo 'Infinity' anedi undadu. 1000 items datithe, array nundi separate collection ki move avvandi."