关闭

M101P: MongoDB for Developers - Chapter 4: Performance

标签: mongodb
322人阅读 评论(0) 收藏 举报
分类:

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-

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:42347次
    • 积分:975
    • 等级:
    • 排名:千里之外
    • 原创:54篇
    • 转载:0篇
    • 译文:0篇
    • 评论:18条
    文章分类
    最新评论