• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
20110514 mongo dbチューニング
 

20110514 mongo dbチューニング

on

  • 36,687 views

第3回MongoDB勉強会の発表資料です。

第3回MongoDB勉強会の発表資料です。

Statistics

Views

Total Views
36,687
Views on SlideShare
12,172
Embed Views
24,515

Actions

Likes
33
Downloads
120
Comments
0

38 Embeds 24,515

http://cloudrop.jp 17132
http://www.nogutetu.com 2399
http://d.hatena.ne.jp 2357
http://ameblo.jp 1371
http://webcache.googleusercontent.com 391
http://gihyo.jp 367
http://dayafterneet.blogspot.jp 104
http://dayafterneet.blogspot.com 99
http://toqoz.hateblo.jp 54
http://infra.rrdtool.net 45
url_unknown 41
http://192.168.207.140 30
http://s.ameblo.jp 23
http://www.slideshare.net 17
http://paper.li 15
http://hatenatunnel.appspot.com 9
https://twitter.com 9
http://excurrent26.memichaud.com 7
http://blog.ameba.jp 6
http://shadianpardaz.com 6
https://www.google.co.jp 4
http://translate.googleusercontent.com 4
http://twitter.com 4
http://us-w1.rockmelt.com 4
http://www.linkedin.com 2
http://49.212.58.95:3000 2
http://localhost 2
http://dayafterneet.blogspot.kr 1
http://cache.yahoofs.jp 1
http://192.168.208.122 1
https://twimg0-a.akamaihd.net 1
http://timprx.appspot.com 1
http://cache.baidu.com 1
http://freeandroidgames.appspot.com 1
http://gaeforyou.appspot.com 1
http://ventil.se 1
http://www.onlydoo.com 1
http://192.168.215.96 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    20110514 mongo dbチューニング 20110514 mongo dbチューニング Presentation Transcript

    • MongoDB id:matsuou1
    • !  !  !  !  !  !   Tips!  
    • !   ID matsuou1!   !   !   !   !   Oracle PostgreSQL!   MongoDB Hadoop R
    • 1. 2. 3. 4. 
    • !  !   RDBMS!  
    • !  !  
    • MongoDB !   !   CPU!   !   JOIN!  
    • •  •  100 insert update delete •  •  nscanned 10• 
    • db/queryoptimizer.cpp
    • !   explain > db.logs.find({uid:"a10Sty5jqqiyxxxx2"}).explain(); { "cursor" : "BasicCursor", "nscanned" : 2669511, "nscannedObjects" : 2669511, "n" : 3, "millis" : 6100, "nYields" : 0, "nChunkSkips" : 0, "isMultiKey" : false, "indexOnly" : false, "indexBounds" : { } }
    • cursor BasicCursor BasicCursor or BtreeCursor nscanned 14 nscannedObjects 14 n 14 millis 9 ms nYields 0nChunkSkips 0 Chunk isMultiKey false indexOnly false indexBounds scanAndOrder allPlans
    • ( ) > db.logs.find({uid:"a10Sty5jqqiyxxxx2"}).explain();{ "cursor" : "BasicCursor", "nscanned" : 2669511, "nscannedObjects" : 2669511, "n" : 3, "millis" : 6100, "nYields" : 0, 6100ms "nChunkSkips" : 0, 3 266 "isMultiKey" : false, "indexOnly" : false, "indexBounds" : { }}
    • ( ) > db.logs.find({uid:"b3iVxMGIEc3xxxxY"}).explain();{ "cursor" : "BtreeCursor uid_1", "nscanned" : 3, "nscannedObjects" : 3, "n" : 3, "millis" : 6, ”uid_1” "nYields" : 0, 6ms "nChunkSkips" : 0, 3 3 "isMultiKey" : false, "indexOnly" : false, "indexBounds" : { "uid" : [ [ "b3iVxMGIEc3xxxxY", "b3iVxMGIEc3xxxxY" ] ] }}
    • !   ! slowms !   ! db.setProfilingLevel(level,slowms) !  
    • slowms !   mongod slowms ms mongod mongod --logpath=/var/log/mongodb/mongodb.log --logappend –slowms 500 Sat May 14 02:25:53 [conn16] query logdb.$cmd ntoreturn:1command: { count: "logs", query: { path: "/index.html" }, fields: {} } reslen:64 3116ms
    • setProfilingLevel setProfilingLevel (level,slowms) > db.setProfilingLevel(1,500); { "was" : 1, "slowms" : 100, "ok" : 1 } 100ms
    • setProfilingLevel system.profile > db.system.profile.find();{ "ts" : ISODate("2011-05-01T03:40:04.462Z"), "info" : "query logdb.logs reslen:192nscanned:2669511 nquery: { uid: "b2kwyYCXn3b5Scpr" } nreturned:1 6686ms","millis" : 6686 } ts millis info query query query nscanned reslen nreturned
    • db.currentOp opid ID KillOp op query update ns query lockType waitingForLock client desc
    • > db.currentOp();{ "inprog" : [ { "opid" : 272, "active" : true, "lockType" : "read", "waitingForLock" : false, "secs_running" : 20, "op" : "query", "ns" : "logdb.logs", "query" : { "count" : "logs", "query" : { "month" : "2010/02" }, "fields" : { } }, "client" : "127.0.0.1:59394", "desc" : "conn" }]}
    • slowms db.setProfilingLevel collection system.profile capped collection db.currentOp MongoDB
    • Tips
    • !   • db.c.find( {x:10,y:20} ), using index {x:1,y:1} • db.c.find( {x:10,y:20} ), using index {x:1,y:-1} • db.c.find( {x:{$in:[10,20]},y:20} ), using index {x:1,y:1} • db.c.find().sort( {x:1,y:1} ), using index {x:1,y:1} • db.c.find().sort( {x:-1,y:1} ), using index {x:1,y:-1} • db.c.find( {x:10} ).sort( {y:1} ), using index {x: 1,y:1}
    • hint !   hint!  
    • hint > db.logs.find({uid:"f2RNwtj34m3xxxxB" , path : "/index.html"}).hint({uid:1}).explain();{ "cursor" : "BtreeCursor uid_1", "nscanned" : 95, "nscannedObjects" : 95, "n" : 35, "millis" : 3, "nYields" : 0, "nChunkSkips" : 0, "isMultiKey" : false, "indexOnly" : false, "indexBounds" : { "uid" : [ [ "f2RNwtj34m3xxxxB", "f2RNwtj34m3xxxxB" ] ] }}
    • hint > db.logs.find({uid:"f2RNwtj34m3xxxxB" , path : "/index.html"}).hint({uid:1 , path:1}).explain();{ "cursor" : "BtreeCursor uid_1_path_1", "nscanned" : 35, "nscannedObjects" : 35, "n" : 35, "millis" : 0, "nYields" : 0, "nChunkSkips" : 0, "isMultiKey" : false, "indexOnly" : false, "indexBounds" : { "uid" : [ [ "f2RNwtj34m3xxxxB", "f2RNwtj34m3xxxxB" ] ], ( ) }}
    • mongostat mongostat
    • mongostat inserts insert / query query / update update / delete delete / getmore getmore / command command / flushes fsync flush / mapped Map MB visze MB res MB faults / locked Idx miss qr|qw read | write ar|aw read | write netIn In bits netOut Out bits conn
    • collection !   getIndexKeys() > db.logs.getIndexKeys(); [ { "_id" : 1 }, { "uid" : 1 }, { "uid" : 1, "path" : 1 } ]
    • !   db.currentOp opid db.killOp(opid) > db.currentOp(); { "inprog" : [ { "opid" : 308, "active" : true, "lockType" : "read", "waitingForLock" : false, "secs_running" : 11, "op" : "query", "ns" : "logdb.logs", ( ) } ] } > db.killOp(308); { "info" : "attempting to kill op" }
    • !  !   !   explain!   !   slowms !   setProfilingLevel !   db.currentOP!   Tips !   !   Hint !   mongostat