🔥 The DB Grill 🔥

Where database blog posts get flame-broiled to perfection

Joining and grouping on array fields in MongoDB may require using $unwind before applying $group or $lookup
Originally from dev.to/feed/franckpachot
August 8, 2025 • Roasted by Patricia "Penny Pincher" Goldman Read Original Article

Alright team, gather ‘round. Someone from Engineering just forwarded me this… uplifting article on MongoDB, and I feel the need to translate it from "developer-speak" into a language we all understand: dollars and cents.

The article opens with the bold claim that “working with nested data in MongoDB simplifies mapping.” Yes, and a Rube Goldberg machine simplifies the process of turning on a light switch. It’s a beautiful, complicated, and entirely unnecessary spectacle that accomplishes something a five-cent component could do instantly.

They present a “challenge.” A challenge, mind you. Not a fundamental design flaw that makes standard reporting feel like performing brain surgery with a spork. The challenge is getting a simple report of who worked on what. In the SQL world, this is a JOIN. It’s the second thing you learn after SELECT *. It’s boring, it’s reliable, and it’s cheap. Here, it’s an adventure. A journey of discovery.

First, they show us the wrong way to do it. How thoughtful. They’re anticipating our developers’ failures, which is good, because I’m anticipating the invoices from the “emergency consultants” we’ll need to hire. They group by the whole team array and get… a useless mess. The article asks, "What went wrong?" What went wrong is that we listened to a sales pitch that promised us a schema-less utopia, and now we’re paying our most expensive engineers to learn a new, counter-intuitive query language just to unwind the chaos we've embedded in our own data.

Their grand solution? $unwind. Doesn't that just sound… relaxing? Like something you’d do at a spa, not something that takes your pristine, “simplified” document, explodes it into a million temporary pieces, chews through your processing credits, and then painstakingly glues it back together. They call this making the data “behave more like SQL’s flattened rows.” So, to be clear: we paid to migrate away from a relational database, and now the premium feature is a command that makes the new database pretend to be the old one? This is genius. It’s like selling someone a boat and then charging them extra for wheels so they can drive it on the highway.

Let’s do some Penny Pincher math, shall we? This isn't just a query. This is a business expense.

So, the “true cost” of this “simple” query isn’t the half-second it takes to run. It's the $987,000 in salaries, consulting fees, and existential dread, followed by a permanent increase in our operational spend. The project in their example is ironically named "Troubleshooting PostgreSQL issues." The real project should be "Troubleshooting our decision to leave PostgreSQL."

They have the audacity to say:

MongoDB is not constrained by normal forms and supports rich document models

That’s like a builder saying, “I’m not constrained by blueprints or load-bearing walls.” It’s not a feature; it’s a terrifying liability. They call it a “rich document model.” I call it a technical debt singularity from which no budget can escape. The entire article is a masterclass in vendor lock-in, disguised as a helpful tutorial. They create the problem, then they sell you the complicated, inefficient, and proprietary solution.

So, thank you for this… enlightening article. It’s a wonderful reminder that when a vendor says their product is “flexible” and “powerful,” they mean it’s flexible enough to find new ways to drain your accounts and powerful enough to bring the entire finance department to its knees. Good work, everyone. Keep these coming. I’m building a fantastic case for just using spreadsheets.