Mongo 3.6
db.setProfilingLevel(2);db.movies.insert({ "title" : "Jaws", "year" : 1995, "imdb" : "tt0073195" });
db.movies.insert({ "title" : "A Clockwork Orange", "year" : 1971, "imdb" : "tt0066921" });
The aggregation
{{db.movies.aggregate( [ { $match:
{ year : 1995 }
} ], { comment : "year_95_query" } );}}
is shown in system.profile as follows:
{{}}{{{ }}
{{ "op" : "command", }}
{{ "ns" : "movies.movies", }}
{{ "command" : {}}
{{ "aggregate" : "movies", }}
{{ "pipeline" : [ { "$match" :
{ "year" : 1995 }
} ], }}
{{ "cursor" : { }, }}
{{ "$db" : "movies", }}
{{ "$readPreference" : { "mode" : "primaryPreferred" }}}
{{ }, }}
{{ "keysExamined" : 0, }}
{{ "docsExamined" : 2, }}
...
Where the old $comment in a $match stage
{{db.movies.aggregate( [ { $match:
{ year : 1995, $comment : "year_95_query" }
} ] );}}
is shown as:
{{{ }}
{{ "op" : "command", }}
{{ "ns" : "movies.movies", }}
{{ "command" : {}}
{{ "aggregate" : "movies", }}
{{ "pipeline" : [ { "$match" :
{ "year" : 1995 }
} ], }}
{{ "cursor" : { }, }}
{{ "$db" : "movies", }}
{{ "$readPreference" : { "mode" : "primaryPreferred" }}}
{{ }, }}
{{ "keysExamined" : 0, }}
{{ "docsExamined" : 2, }}
{{ ...}}