Thursday, August 28, 2014

M101J: MongoDB for Java Developers Homework 4.2

M101J: MongoDB for Java Developers Homework 4.2
Question:
Suppose you have a collection called tweets whose documents contain information about the created_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"
}
 
Option:
 
1) This query performs a collection scan.  
True, it perform a collection scan.
 
2)The query uses an index to determine the order in which to return result documents. 
True, it uses an index to determine result
 
3)The query uses an index to determine which documents match.
false, for matches there is no index, index are use only for ordering.
 
4) The query returns 46462 documents. 
false, You can see the query it has limit to 10 , so it return only 10 result.
 
5)The query visits 46462 documents. 
true,  yes it has scanned 46462 document.
 
6)The query is a "covered index query". 
false, query is colvered index query.
 
So answer for week 4 - Homework 4.2 are 
 
 
  
   
  

No comments:

Post a Comment