Homework 4.1
- (OK)
db.products.find( { $and : [ { price : { $gt : 30 } }, { price : { $lt : 50 } } ] } ).sort( { brand : 1 } )
db.products.find( { 'brand' : "GE" } )
db.products.find( { brand : 'GE' } ).sort( { category : 1, brand : -1 } )
- (OK)
db.products.find( { 'brand' : "GE" } ).sort( { price : 1 } )
Homework 4.2
- (OK) The query uses an index to determine the order in which to return result documents.
- The query uses an index to determine which documents match.
- (OK) The query examines 251120 documents.
- The query returns 251120 documents.
- The query is a covered query.
Homework 4.3
db.posts.createIndex({date:-1})
db.posts.createIndex({tags:1,date:-1})
db.posts.createIndex({permalink:1})
Homework 4.4
> db.profile.find().sort({millis:-1}).limit(1).pretty()
{
"_id" : ObjectId("57c41c92adaa1d1ee896b853"),
"ts" : ISODate("2012-11-20T20:09:49.862Z"),
"op" : "query",
"ns" : "school2.students",
"query" : {
"student_id" : 80
},
"ntoreturn" : 0,
"ntoskip" : 0,
"nscanned" : 10000000,
"keyUpdates" : 0,
"numYield" : 5,
"lockStats" : {
"timeLockedMicros" : {
"r" : 19776550,
"w" : 0
},
"timeAcquiringMicros" : {
"r" : 4134067,
"w" : 5
}
},
"nreturned" : 10,
"responseLength" : 2350,
"millis" : 15820,
"client" : "127.0.0.1",
"user" : ""
}
15820
-eof-