Homework: Homework 4.1
> db.products.getIndexes() [ { "v" : 1, "key" : { "_id" : 1 }, "ns" : "store.products", "name" : "_id_" }, { "v" : 1, "key" : { "sku" : 1 }, "unique" : true, "ns" : "store.products", "name" : "sku_1" }, { "v" : 1, "key" : { "price" : -1 }, "ns" : "store.products", "name" : "price_-1" }, { "v" : 1, "key" : { "description" : 1 }, "ns" : "store.products", "name" : "description_1" }, { "v" : 1, "key" : { "category" : 1, "brand" : 1 }, "ns" : "store.products", "name" : "category_1_brand_1" }, { "v" : 1, "key" : { "reviews.author" : 1 }, "ns" : "store.products", "name" : "reviews.author_1" }Which of the following queries can utilize an index. Check all that apply.
Homework: Homework 4.2
Suppose you have a collection called tweets whose documents contain information about thecreated_at time of the tweet and the user's followers_count at the time they issued the tweet. What can you infer from the following explain output?db.tweets.find({"user.followers_count":{$gt:1000}}).sort({"created_at" : 1 }).limit(10).skip(5000).explain()
{
"cursor" : "BtreeCursor created_at_-1 reverse",
"isMultiKey" : false,
"n" : 10,
"nscannedObjects" : 46462,
"nscanned" : 46462,
"nscannedObjectsAllPlans" : 49763,
"nscannedAllPlans" : 49763,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 205,
"indexBounds" : {
"created_at" : [
[
{
"$minElement" : 1
},
{
"$maxElement" : 1
}
]
]
},
"server" : "localhost.localdomain:27017"
}
db.tweets.find({"user.followers_count":{$gt:1000}}).sort({"created_at" : 1 }).limit(10).skip(5000).explain() { "cursor" : "BtreeCursor created_at_-1 reverse", "isMultiKey" : false, "n" : 10, "nscannedObjects" : 46462, "nscanned" : 46462, "nscannedObjectsAllPlans" : 49763, "nscannedAllPlans" : 49763, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 205, "indexBounds" : { "created_at" : [ [ { "$minElement" : 1 }, { "$maxElement" : 1 } ] ] }, "server" : "localhost.localdomain:27017" }
Homework: Homework 4.3
Пишем 3 строки для добавления индексов:
db.posts.ensureIndex({date:-1})
db.posts.ensureIndex({permalink:-1})
db.posts.ensureIndex({tags:-1,date:-1})
В итоге:
Tests Passed for HW 4.3. Your HW 4.3 validation code is 34f9jr29sh29f20fsplinv
Homework: Homework 4.4
mongoimport -d m101 -c profile < sysprofile.jsonNow query the profile data, looking for all queries to the students collection in the database school2, sorted in order of decreasing latency. What is the latency of the longest running operation to the collection, in milliseconds?
ОтветитьУдалитьGreat Effort by the Author. I have gone through your post and it was simple and wrote so simply that any person can understand.While doing Mongodb Cerfitication i found one more website on which i found mongodb certification answers http://www.visionfortech.com/p/mongodb-certificate-s.html