1 thought on “Learn About The Concept of Covered Queries in MongoDB

  1. > db.covered_queries.find ({occupation: “Employed”}, {name: 1, gender: 1}) I ran the above command with adding a explainable object i.e, db.covered_queries.explain().find ({occupation: “Employed”}, {name: 1, gender: 1}) to see the execution plans. It seems like the queries does a collection scan not an index scan.
    I also checked if my index is correct not but the index is correct as well.
    {
    “v” : 1,
    “key” : {
    “gender” : 1,
    “name” : 1,
    “occupation” : 1
    },
    “name” : “gender_1_name_1_occupation_1”,
    “ns” : “week5.covered_queries”
    }
    When i ran the query with explainable method, i got the following

    },
    “winningPlan” : {
    “stage” : “PROJECTION”,
    “transformBy” : {
    “name” : 1,
    “gender” : 1
    },
    “inputStage” : {
    “stage” : “COLLSCAN”,
    “filter” : {
    “occupation” : {
    “$eq” : “Employed”
    }
    },
    “direction” : “forward”
    }
    },

Leave a Reply

Your email address will not be published. Required fields are marked *