Q:

MongoDB aggregate queries vs. MySQL SELECT field1 FROM table

I am completely new to MongoDB and wanted to compare query performance of a NoSQL data model relative to its relational database counter part.  I wrote this into MongoDB shell
// Make 10 businesses
// Each business has 10 locations
// Each location has 10 departments
// Each department has 10 teams
// Each team has 100 employees
(new Array(10)).fill(0).forEach(_=>
    db.businesses.insert({
        "name":"Business Name",
        "locations":(new Array(10)).fill(0).map(_=>({
            "name":"Office Location",
            "departments":(new Array(10)).fill(0).map(_=>({
                "name":"Department",
                "teams":(new Array(10)).fill(0).map(_=>({
                    "name":"Team Name",
                    "employees":(new Array(100)).fill(0).map(_=>({
                        "age":Math.floor(Math.random()*100)
                    }))
                }))
            }))
        }))
    })
);

Then I attempted the equivalent of MySQL's EXPLAIN SELECT age,name,(and a few other fields) FROM employees WHERE age >= 50 ORDER BY age DESC by writing this statement:
db.businesses.aggregate([
    { $unwind: "$locations" },
    { $unwind: "$locations.departments" },
    { $unwind: "$locations.departments.teams" },
    { $unwind: "$locations.departments.teams.employees" },
    { $project: { _id: 0, age: "$locations.departments.teams.employees.age" } },
    { $match: { "age": { $gte: 50 }} },
    { $sort: {"age" : -1}}
]).explain("executionStats")

The result was: 

"errmsg" : "Sort exceeded memory limit of 104857600 bytes, but did not
  opt in to external sorting. Aborting operation. Pass allowDiskUse:true
  to opt in.",

So I deleted the sort clause and try to get an explain.  But the result was:

TypeError: db.businesses.aggregate(...).explain is not a function

So my questions are:

Primarily, I want to know the performance difference of SELECT age FROM employees WHERE age >= 50 ORDER BY age DESC when compared with the MongoDB's aggregate query counter part.  Is it more or less the same? Will one be substantially faster or more performant than the other?
Alternatively, how do I fix my MongoDB query so that I can get performance details to compare against my MySQL query counter part?

A:

Employees are single entities; thus, you probably don't want to model age of a team member so deeply in the rich structure of departments and locations and teams.   It is perfectly fine to have a separate employees collection and simply do:
db.businesses.aggregate([
{$match: {"age": {$gt: 50} }}
,{$sort: {"age": -1} }
]);

Deep in your businesses collection you can have:
{ teams: [ {name: "T1", employees: [ "E1", "E34" ]} ] }

Alternately, try this:
db.businesses.aggregate([ your pipeline] ,{allowDiskUse:true});

The OP has a setup of 10 biz -> 10 loc -> 10 depts -> 10 teams -> 100 emps.  The first 3 unwinds creates a 10000x explosion of data but the last one is 100x beyond that.  We can shrink the hit by using $filter:
db.businesses.aggregate([
{ $unwind: "$locations" },
{ $unwind: "$locations.departments" },
{ $unwind: "$locations.departments.teams" },

{$project: {
        XX: {$filter: {
                    input: "$locations.departments.teams.employees",
                    as: "z",
                    cond: {$gte: [ "$$z.age", 50] }
            }}
    }}
,{$unwind: "$XX"}
,{$sort: {"XX.age":-1}}])

