SlideShare a Scribd company logo
1 of 34
Download to read offline
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	
            0
nChunkSkips	
        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:1
command: { 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:192
nscanned: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
MongoDB Tips for Performance and Optimization

More Related Content

What's hot

Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMongoDB
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarMongoDB
 
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...MongoDB
 
Mongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongoDB
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsAlexander Rubin
 
MongoDB dla administratora
MongoDB dla administratora MongoDB dla administratora
MongoDB dla administratora 3camp
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineJason Terpko
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance TuningMongoDB
 
Optimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityOptimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityMongoDB
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduceMongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduceTakahiro Inoue
 
PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへBasuke Suzuki
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsServer Density
 

What's hot (20)

Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
 
Elastic search 검색
Elastic search 검색Elastic search 검색
Elastic search 검색
 
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
 
Mongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongodb debugging-performance-problems
Mongodb debugging-performance-problems
 
MongoDB-SESSION03
MongoDB-SESSION03MongoDB-SESSION03
MongoDB-SESSION03
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
MongoDB dla administratora
MongoDB dla administratora MongoDB dla administratora
MongoDB dla administratora
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Mongo db dla administratora
Mongo db dla administratoraMongo db dla administratora
Mongo db dla administratora
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
Optimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityOptimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and Creativity
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduceMongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
 
PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへ
 
Latinoware
LatinowareLatinoware
Latinoware
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 

Similar to MongoDB Tips for Performance and Optimization

Running Production MongoDB Lightning Talk
Running Production MongoDB Lightning TalkRunning Production MongoDB Lightning Talk
Running Production MongoDB Lightning Talkchrisckchang
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live HackingTobias Trelle
 
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例Naoki Sega
 
MongoDB Europe 2016 - Debugging MongoDB Performance
MongoDB Europe 2016 - Debugging MongoDB PerformanceMongoDB Europe 2016 - Debugging MongoDB Performance
MongoDB Europe 2016 - Debugging MongoDB PerformanceMongoDB
 
MongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームMongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームSuguru Namura
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big DataTakahiro Inoue
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!Daniel Cousineau
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...MongoDB
 
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Lucidworks
 
rsyslog v8: more than just syslog!
rsyslog v8: more than just syslog!rsyslog v8: more than just syslog!
rsyslog v8: more than just syslog!Yury Bushmelev
 
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop ConnectorMongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop ConnectorMongoDB
 
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingMongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingJason Terpko
 
第一回MongoDBソースコードリーディング
第一回MongoDBソースコードリーディング第一回MongoDBソースコードリーディング
第一回MongoDBソースコードリーディングnobu_k
 
Elastic Search Training#1 (brief tutorial)-ESCC#1
Elastic Search Training#1 (brief tutorial)-ESCC#1Elastic Search Training#1 (brief tutorial)-ESCC#1
Elastic Search Training#1 (brief tutorial)-ESCC#1medcl
 
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...MongoDB
 
Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012Bip Thelin
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators iammutex
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingMyles Braithwaite
 
Shell Tips & Tricks
Shell Tips & TricksShell Tips & Tricks
Shell Tips & TricksMongoDB
 

Similar to MongoDB Tips for Performance and Optimization (20)

Mongo scaling
Mongo scalingMongo scaling
Mongo scaling
 
Running Production MongoDB Lightning Talk
Running Production MongoDB Lightning TalkRunning Production MongoDB Lightning Talk
Running Production MongoDB Lightning Talk
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
 
MongoDB Europe 2016 - Debugging MongoDB Performance
MongoDB Europe 2016 - Debugging MongoDB PerformanceMongoDB Europe 2016 - Debugging MongoDB Performance
MongoDB Europe 2016 - Debugging MongoDB Performance
 
MongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームMongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲーム
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
 
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
 
rsyslog v8: more than just syslog!
rsyslog v8: more than just syslog!rsyslog v8: more than just syslog!
rsyslog v8: more than just syslog!
 
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop ConnectorMongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
MongoDB Days Silicon Valley: MongoDB and the Hadoop Connector
 
MongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and MergingMongoDB Chunks - Distribution, Splitting, and Merging
MongoDB Chunks - Distribution, Splitting, and Merging
 
第一回MongoDBソースコードリーディング
第一回MongoDBソースコードリーディング第一回MongoDBソースコードリーディング
第一回MongoDBソースコードリーディング
 
Elastic Search Training#1 (brief tutorial)-ESCC#1
Elastic Search Training#1 (brief tutorial)-ESCC#1Elastic Search Training#1 (brief tutorial)-ESCC#1
Elastic Search Training#1 (brief tutorial)-ESCC#1
 
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
 
Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012Riak Meetup Stockholm 1/11/2012
Riak Meetup Stockholm 1/11/2012
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
 
Shell Tips & Tricks
Shell Tips & TricksShell Tips & Tricks
Shell Tips & Tricks
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

MongoDB Tips for Performance and Optimization

  • 1. MongoDB id:matsuou1
  • 2. !   !   !   !   !   !   Tips !  
  • 3. !   ID matsuou1 !   !   !   !   !   Oracle PostgreSQL !   MongoDB Hadoop R
  • 5.
  • 6. !   !   RDBMS !  
  • 8. MongoDB !   !   CPU !   !   JOIN !  
  • 9. •  •  100 insert update delete •  •  nscanned 10 • 
  • 11.
  • 12. !   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" : { } }
  • 13. cursor BasicCursor BasicCursor or BtreeCursor nscanned 14 nscannedObjects 14 n 14 millis 9 ms nYields 0 nChunkSkips 0 Chunk isMultiKey false indexOnly false indexBounds scanAndOrder allPlans
  • 14. ( ) > 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" : { } }
  • 15. ( ) > 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" ] ] } }
  • 16.
  • 17. !   ! slowms !   ! db.setProfilingLevel(level,slowms) !  
  • 18. 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:1 command: { count: "logs", query: { path: "/index.html" }, fields: {} } reslen:64 3116ms
  • 19. setProfilingLevel setProfilingLevel (level,slowms) > db.setProfilingLevel(1,500); { "was" : 1, "slowms" : 100, "ok" : 1 } 100ms
  • 20. setProfilingLevel system.profile > db.system.profile.find(); { "ts" : ISODate("2011-05-01T03:40:04.462Z"), "info" : "query logdb.logs reslen:192 nscanned:2669511 nquery: { uid: "b2kwyYCXn3b5Scpr" } nreturned:1 6686ms", "millis" : 6686 } ts millis info query query query nscanned reslen nreturned
  • 21. db.currentOp opid ID KillOp op query update ns query lockType waitingForLock client desc
  • 22. > 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" }]}
  • 23. slowms db.setProfilingLevel collection system.profile capped collection db.currentOp MongoDB
  • 24. Tips
  • 25. !   • 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}
  • 26. hint !   hint !  
  • 27. 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" ] ] } }
  • 28. 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" ] ], ( ) } }
  • 29. mongostat mongostat
  • 30. 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
  • 31. collection !   getIndexKeys() > db.logs.getIndexKeys(); [ { "_id" : 1 }, { "uid" : 1 }, { "uid" : 1, "path" : 1 } ]
  • 32. !   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" }
  • 33. !   !   !   explain !   !   slowms !   setProfilingLevel !   db.currentOP !   Tips !   !   Hint !   mongostat