Lab 4.2: Aggregation Performance - explain for pipeline

Hi,
i created an index on …
I used the command below to explain the result.
Is it correct?
Is there any else way to do the same?
Thanks

db.runCommand(
{
explain: {
aggregate: “restaurants”,
pipeline: [
{ $match: { stars: { $gt: 2 } } },
{ $sort: { stars: 1 } },
{ $group: { _id: “$cuisine”, count: { $sum: 1 } } }
],
cursor: {}
},
verbosity: “executionStats”
}
)

I suggest taking another look at the lecture on aggregation performance, around 2:59, which shows the syntax for explaining an aggregation pipeline.

1 Like

Thx Simon!
Simplier than my solution.

You’re welcome :slight_smile: