executionTimeMillisEstimate meaning in explain() executionStats for aggregation pipeline

171 views Asked by At

I have done the following explain() with executionStats verbosity for an aggregation pipeline in my MongoDB instance:

> db.users.explain("executionStats").aggregate([ ... ])
{
    "explainVersion" : "1",
    "stages" : [
        {
            "$cursor" : { ... },
             ...
            "executionTimeMillisEstimate" : NumberLong(0)
        },
        {
            "$lookup" : { ... },
            ...
            "executionTimeMillisEstimate" : NumberLong(308)
        },
        {
            "$lookup" : { ... },            
            ...
            "executionTimeMillisEstimate" : NumberLong(1297)
        },
        {
            "$project" : { ... },
            ...
            "executionTimeMillisEstimate" : NumberLong(1320)
        },
        {
            "$project" : { ...},
            ...
            "executionTimeMillisEstimate" : NumberLong(1323)
        }
    ],
    ...
}

The aggregation detail itself is not important in the context of this question, so I have simplified it. The only thing to take into account is that is that the pipeline is composed of the following stages:

  • match
  • (first) lookup
  • (second) lookup
  • (first) project
  • (second) project

I understand that executionTimeMillisEstimate doesn't mean the time it takes that particular stage but the time measured from the moment in which the operation started. Thus, the actual estimate time for each stage is:

  • match: 0ms (I have an index for the query, so makes sense it is very fast)
  • (first) lookup: 308 - 0 = 308ms
  • (second) lookup: 1297 - 308 = 989ms
  • (first) project: 1320 - 1297 = 23ms
  • (second) project: 1323 - 1320 = 3ms

Is my understanding on how executionTimeMillisEstimate correct, please?

Thanks in advance!

0

There are 0 answers