No SORT_KEY_GENERATOR stage

Hello,

I imported people.json file into people collection.

Here is the result when I run db.people.getIndexes()

[
  {
    "v": 2,
    "key": {
      "_id": 1
    },
    "name": "_id_"
  },
  {
    "v": 2,
    "key": {
      "last_name": 1,
      "address.state": 1
    },
    "name": "last_name_1_address.state_1"
  }
]

Following along with Chapter 2, Lecture: Understanding Explain Part 1, when I execute the following query, I do not see any stage called SORT_KEY_GENERATOR.

db.people
      .explain('executionStats')
      .find({ last_name: 'Johnson', 'address.state': 'New York' })
      .sort({ birthday:1 })

And here is the result:

{
  "queryPlanner": {
    "plannerVersion": 1,
    "namespace": "M201.people",
    "indexFilterSet": false,
    "parsedQuery": {
      "$and": [
        {
          "address.state": {
            "$eq": "New York"
          }
        },
        {
          "last_name": {
            "$eq": "Johnson"
          }
        }
      ]
    },
    "winningPlan": {
      "stage": "SORT",
      "sortPattern": {
        "birthday": 1
      },
      "memLimit": 33554432,
      "type": "simple",
      "inputStage": {
        "stage": "FETCH",
        "inputStage": {
          "stage": "IXSCAN",
          "keyPattern": {
            "last_name": 1,
            "address.state": 1
          },
          "indexName": "last_name_1_address.state_1",
          "isMultiKey": false,
          "multiKeyPaths": {
            "last_name": [],
            "address.state": []
          },
          "isUnique": false,
          "isSparse": false,
          "isPartial": false,
          "indexVersion": 2,
          "direction": "forward",
          "indexBounds": {
            "last_name": [
              "[\"Johnson\", \"Johnson\"]"
            ],
            "address.state": [
              "[\"New York\", \"New York\"]"
            ]
          }
        }
      }
    },
    "rejectedPlans": []
  },
  "executionStats": {
    "executionSuccess": true,
    "nReturned": 7,
    "executionTimeMillis": 0,
    "totalKeysExamined": 7,
    "totalDocsExamined": 7,
    "executionStages": {
      "stage": "SORT",
      "nReturned": 7,
      "executionTimeMillisEstimate": 0,
      "works": 16,
      "advanced": 7,
      "needTime": 8,
      "needYield": 0,
      "saveState": 0,
      "restoreState": 0,
      "isEOF": 1,
      "sortPattern": {
        "birthday": 1
      },
      "memLimit": 33554432,
      "type": "simple",
      "totalDataSizeSorted": 2950,
      "usedDisk": false,
      "inputStage": {
        "stage": "FETCH",
        "nReturned": 7,
        "executionTimeMillisEstimate": 0,
        "works": 8,
        "advanced": 7,
        "needTime": 0,
        "needYield": 0,
        "saveState": 0,
        "restoreState": 0,
        "isEOF": 1,
        "docsExamined": 7,
        "alreadyHasObj": 0,
        "inputStage": {
          "stage": "IXSCAN",
          "nReturned": 7,
          "executionTimeMillisEstimate": 0,
          "works": 8,
          "advanced": 7,
          "needTime": 0,
          "needYield": 0,
          "saveState": 0,
          "restoreState": 0,
          "isEOF": 1,
          "keyPattern": {
            "last_name": 1,
            "address.state": 1
          },
          "indexName": "last_name_1_address.state_1",
          "isMultiKey": false,
          "multiKeyPaths": {
            "last_name": [],
            "address.state": []
          },
          "isUnique": false,
          "isSparse": false,
          "isPartial": false,
          "indexVersion": 2,
          "direction": "forward",
          "indexBounds": {
            "last_name": [
              "[\"Johnson\", \"Johnson\"]"
            ],
            "address.state": [
              "[\"New York\", \"New York\"]"
            ]
          },
          "keysExamined": 7,
          "seeks": 1,
          "dupsTested": 0,
          "dupsDropped": 0
        }
      }
    }
  },
  "serverInfo": {
    "host": "typegoosecluster-shard-00-02.pqfys.mongodb.net",
    "port": 27017,
    "version": "4.4.6",
    "gitVersion": "72e66213c2c3eab37d9358d5e78ad7f5c1d0d0d7"
  },
  "ok": 1,
  "$clusterTime": {
    "clusterTime": {
      "$timestamp": {
        "t": 0,
        "i": 0
      }
    },
    "signature": {
      "hash": {
        "$binary": {
          "base64": "bhrzqFXnPBt2Lq7RKhyZssb7EnI=",
          "subType": "00"
        }
      },
      "keyId": 6950760349251404000
    }
  },
  "operationTime": {
    "$timestamp": {
      "t": 0,
      "i": 0
    }
  }
}

Why is the executionStats object lacks SORT_KEY_GENERATOR stage wherein it is present in the lecture?

Hi @Omer_Toraman1

I’ll point you to first Lab 3.1 Explain Output - #2 by Eoin_Brazil and then to this post Lesson 3.9 Understanding Explain Part I - #2 by Eoin_Brazil.

Essentially, it is likely the lack of the stage is mostly likely due to running a later version of the shell (first post) and in my second post, I’ll drill a little more down into that stage and equivalents for it.

Hope these help answer your question.

Kindest reegards,
Eoin

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.