SlideShare ist ein Scribd-Unternehmen logo
1 von 21
ankur.raina@mongodb.com
MongoDB Performance
Tuning
Performance? Fast?
Performance Tuning vs Optimizing
‱ Optimizing – Opportunity to restructure
your application, data model, and
queries
‱ Performance Tuning – Experiment and
modify system
Hardware
CPU / RAM / HDD / OS
Topology / Network / Hosting
Application
Input - sources of write traffic
Output - sources of query load
Schema
MongoDB
Replica-set configuration, tags, read & write concern
Shard configuration, tags, shard keys
Where to Focus?
Investigation
Log files, Profiler, Query Optimizer
mongod
log file
profiler (collection)
query engine
Query Planner
Explain Levels in MongoDB 3.x
‱ queryPlanner (default level): runs the query planner and chooses the winning plan without
actually executing the query
– Use case: "Which plan will MongoDB choose to run my query?"
‱ executionStats – runs the query optimizer, then runs the winning plan to completion
– Use case: "How is my query performing?"
‱ allPlansExecution – same as executionStats, but returns all the query plans, not just the winning
plan.
– Use case: "I want as much information as possible to diagnose a slow query."
db.employees.findOne()
{
"_id" : ObjectId("592bebaa7761b028cdec1b6f"),
"last_name" : "Pham",
"quote" : "Aliquam est reiciendis alias neque ad.",
"job" : "Counselling psychologist",
"ssn" : "401-31-6615",
"address" : {
"city" : "Lake Meaganton",
"state" : "Idaho",
"street" : "83248 Woods Extension",
"zip" : "10914-3394"
},
"first_name" : "Yvonne",
"company_id" : ObjectId("58bdbe32500b1d42c7e10be7"),
"employer" : "Terry and Sons",
"birthday" : ISODate("2011-04-17T21:19:28Z"),
"email" : "murillobrian@cox.net"
}
db.employees.count()
1010893
db.employees.getIndexes()
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "MUGDB.employees"
}
]
QUERY:
db.employees.find({"first_name":"Yvonne"}).sort({"last_name":1})
2017-05-29T09:54:07.829+0000 I COMMAND [conn286] command
MUGDB.employees appName: "MongoDB Shell" command: find { find: "employees",
filter: { first_name: "Yvonne" }, sort: { last_name: 1.0 } } planSummary: COLLSCAN
cursorid:69354336473 keysExamined:0 docsExamined:1010893 hasSortStage:1
numYields:7900 nreturned:101 reslen:39605 locks:{ Global: { acquireCount: { r:
15802 } }, Database: { acquireCount: { r: 7901 } }, Collection: { acquireCount: { r: 7901
} } } protocol:op_command 480ms
Ohhhh! Ok!
db.employees.find({"first_name":"Yvonne"}).sort({"last_name":1}).explain(true)
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "MUGDB.employees",
"indexFilterSet" : false,
"parsedQuery" : {
"first_name" : {
"$eq" : "Yvonne"
}
},
"winningPlan" : {
"stage" : "SORT",
"sortPattern" : {
"last_name" : 1
},
"inputStage" : {
"stage" :
"SORT_KEY_GENERATOR",
"inputStage" : {
"stage" :
"COLLSCAN",
"filter" : {
"first_name" : {
"$eq" : "Yvonne"
}
},
"direction" : "forward"
}
}
},
"rejectedPlans" : [ ]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 498,
"executionTimeMillis" : 480,
"totalKeysExamined" : 0,
"totalDocsExamined" : 1010893,
"executionStages" : {
"stage" : "SORT",
"nReturned" : 498,
"executionTimeMillisEstimate" : 0,
"works" : 1011395,
"advanced" : 498,
"needTime" : 1010896,
"needYield" : 0,
"saveState" : 7901,
"restoreState" : 7901,
"isEOF" : 1,
"invalidates" : 0,
"sortPattern" : {
"last_name" : 1
},
"memUsage" : 196424,
"memLimit" : 33554432,
"inputStage" : {
"stage" : "SORT_KEY_GENERATOR",
"nReturned" : 498,
"executionTimeMillisEstimate" : 0,
"works" : 1010896,
"advanced" : 498,
"needTime" : 1010397,
"needYield" : 0,
"saveState" : 7901,
"restoreState" : 7901,
"isEOF" : 1,
"invalidates" : 0,
"inputStage" : {
"stage" :
"COLLSCAN",
"filter" : {
"first_name" : {
"$eq" : "Yvonne"
}
},
"nReturned" : 498,
"executionTimeMillisEstimate" : 0,
"works" : 1010895,
"advanced" : 498,
"needTime" :
1010396,
"needYield" : 0,
"saveState" : 7901,
"restoreState" :
7901,
"isEOF" : 1,
"invalidates" : 0,
"allPlansExecution" : [ ]
},
"serverInfo" : {
"host" : "m312",
"port" : 30000,
"version" : "3.4.2",
"gitVersion" : "3f76e40c105fc223b3e5aac3e20dcd026b83b38b"
},
"ok" : 1
}
Create Index
db.employees.createIndex({"first_name":1, "last_name":1}
2017-05-29T10:05:48.432+0000 I COMMAND [conn286] command MUGDB.$cmd
appName: "MongoDB Shell" command: createIndexes { createIndexes: "employees",
indexes: [ { key: { first_name: 1.0, last_name: 1.0 }, name:
"first_name_1_last_name_1" } ] } numYields:0 reslen:98 locks:{ Global: {
acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 1, W: 1 } }, Collection: {
acquireCount: { w: 1 } }, Metadata: { acquireCount: { w: 1 } }, oplog: { acquireCount: {
w: 1 } } } protocol:op_command 4578ms
MongoDB Enterprise m312RS:PRIMARY> db.employees.find({"first_name":"Yvonne"}).sort({"last_name":1}).explain(true)
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "MUGDB.employees",
"indexFilterSet" : false,
"parsedQuery" : {
"first_name" : {
"$eq" : "Yvonne"
}
},
"winningPlan" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"first_name" : 1,
"last_name" : 1
},
"indexName" : "first_name_1_last_name_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"first_name" : [ ],
"last_name" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"first_name" : [
"["Yvonne", "Yvonne"]"
],
"last_name" : [
"[MinKey, MaxKey]"
]
}
}
},
"rejectedPlans" : [ ]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 498,
"executionTimeMillis" : 7,
"totalKeysExamined" : 498,
"totalDocsExamined" : 498,
"executionStages" : {
"stage" : "FETCH",
"nReturned" : 498,
"executionTimeMillisEstimate" : 0,
"works" : 499,
"advanced" : 498,
"needTime" : 0,
"needYield" : 0,
"saveState" : 3,
"restoreState" : 3,
"isEOF" : 1,
"invalidates" : 0,
"docsExamined" : 498,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "IXSCAN",
"nReturned" : 498,
"executionTimeMillisEstimate" : 0,
"works" : 499,
"advanced" : 498,
"needTime" : 0,
"needYield" : 0,
"saveState" : 3,
"restoreState" : 3,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"first_name" : 1,
"last_name" : 1
},
"indexName" :
"first_name_1_last_name_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"first_name" : [ ],
"last_name" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"first_name" : [
"["Yvonne", "Yvonne"]"
],
"last_name" : [
"[MinKey, MaxKey]"
]
},
"keysExamined" : 498,
"seeks" : 1,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
}
},
"allPlansExecution" : [ ]
},
"serverInfo" : {
"host" : "m312",
"port" : 30000,
"version" : "3.4.2",
"gitVersion" : "3f76e40c105fc223b3e5aac3e20dcd026b83b38b"
},
"ok" : 1
}
$indexStats
db.employees.aggregate( [ { $indexStats: { } } ] )
{ "name" : "_id_", "key" : { "_id" : 1 }, "host" : "m312:30000", "accesses" : { "ops" :
NumberLong(1), "since" : ISODate("2017-05-29T09:36:42.253Z") } }
{ "name" : "first_name_1_last_name_1", "key" : { "first_name" : 1, "last_name" : 1 },
"host" : "m312:30000", "accesses" : { "ops" : NumberLong(1), "since" :
ISODate("2017-05-29T10:05:43.856Z") } }
To Be Continued
 Questions?
When?
‱ Next MUG
‱ Focus Point?
‱ Which other performance issues would you like to talk about?
What else can I check?
MongoDB University Free Courses ( https://university.mongodb.com/ )
‱ M201: MongoDB Performance
‱ M312: Diagnostics and Debugging

Weitere Àhnliche Inhalte

Was ist angesagt?

WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...
GeeksLab Odessa
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
clkao
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 
R57shell
R57shellR57shell
R57shell
ady36
 
Api docs v3.0
Api docs v3.0Api docs v3.0
Api docs v3.0
Anh Tuan
 

Was ist angesagt? (20)

Developing cacheable backend applications - Appdevcon 2019
Developing cacheable backend applications - Appdevcon 2019Developing cacheable backend applications - Appdevcon 2019
Developing cacheable backend applications - Appdevcon 2019
 
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - мроĐč ЧаĐčĐșĐŸĐČ...
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platform
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
php plus mysql
php plus mysqlphp plus mysql
php plus mysql
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Security: Odoo Code Hardening
Security: Odoo Code HardeningSecurity: Odoo Code Hardening
Security: Odoo Code Hardening
 
rsyslog v8: more than just syslog!
rsyslog v8: more than just syslog!rsyslog v8: more than just syslog!
rsyslog v8: more than just syslog!
 
R57shell
R57shellR57shell
R57shell
 
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
 
20110514 mongo dbăƒăƒ„ăƒŒăƒ‹ăƒłă‚°
20110514 mongo dbăƒăƒ„ăƒŒăƒ‹ăƒłă‚°20110514 mongo dbăƒăƒ„ăƒŒăƒ‹ăƒłă‚°
20110514 mongo dbăƒăƒ„ăƒŒăƒ‹ăƒłă‚°
 
JavaScript Proxy (ES6)
JavaScript Proxy (ES6)JavaScript Proxy (ES6)
JavaScript Proxy (ES6)
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
Gta v savegame
Gta v savegameGta v savegame
Gta v savegame
 
DevOps Fest 2019. ХДргДĐč ĐœĐ°Ń€Ń‡Đ”ĐœĐșĐŸ. Terraform: a novel about modules, provider...
DevOps Fest 2019. ХДргДĐč ĐœĐ°Ń€Ń‡Đ”ĐœĐșĐŸ. Terraform: a novel about modules, provider...DevOps Fest 2019. ХДргДĐč ĐœĐ°Ń€Ń‡Đ”ĐœĐșĐŸ. Terraform: a novel about modules, provider...
DevOps Fest 2019. ХДргДĐč ĐœĐ°Ń€Ń‡Đ”ĐœĐșĐŸ. Terraform: a novel about modules, provider...
 
Search Evolution - Von Lucene zu Solr und ElasticSearch
Search Evolution - Von Lucene zu Solr und ElasticSearchSearch Evolution - Von Lucene zu Solr und ElasticSearch
Search Evolution - Von Lucene zu Solr und ElasticSearch
 
quick json parser
quick json parserquick json parser
quick json parser
 
Agile Testing Days 2018 - API Fundamentals - postman collection
Agile Testing Days 2018 - API Fundamentals - postman collectionAgile Testing Days 2018 - API Fundamentals - postman collection
Agile Testing Days 2018 - API Fundamentals - postman collection
 
Api docs v3.0
Api docs v3.0Api docs v3.0
Api docs v3.0
 
Mongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongodb debugging-performance-problems
Mongodb debugging-performance-problems
 

Ähnlich wie Mug17 gurgaon

MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
Edward Capriolo
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
Ingvar Stepanyan
 
Unit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeUnit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and Node
Josh Mock
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
Scott Hamilton
 

Ähnlich wie Mug17 gurgaon (20)

Webinar: Index Tuning and Evaluation
Webinar: Index Tuning and EvaluationWebinar: Index Tuning and Evaluation
Webinar: Index Tuning and Evaluation
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017
Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017
Full-Text Search Explained - Philipp Krenn - Codemotion Rome 2017
 
(SDD411) Amazon CloudSearch Deep Dive and Best Practices | AWS re:Invent 2014
(SDD411) Amazon CloudSearch Deep Dive and Best Practices | AWS re:Invent 2014(SDD411) Amazon CloudSearch Deep Dive and Best Practices | AWS re:Invent 2014
(SDD411) Amazon CloudSearch Deep Dive and Best Practices | AWS re:Invent 2014
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Splitapp coding
Splitapp codingSplitapp coding
Splitapp coding
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
GraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup SlidesGraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup Slides
 
Unit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeUnit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and Node
 
Keeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETLKeeping Spark on Track: Productionizing Spark for ETL
Keeping Spark on Track: Productionizing Spark for ETL
 
NodeJs
NodeJsNodeJs
NodeJs
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlin
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
 
Introduction to-mongo db-execution-plan-optimizer-final
Introduction to-mongo db-execution-plan-optimizer-finalIntroduction to-mongo db-execution-plan-optimizer-final
Introduction to-mongo db-execution-plan-optimizer-final
 
Introduction to Mongodb execution plan and optimizer
Introduction to Mongodb execution plan and optimizerIntroduction to Mongodb execution plan and optimizer
Introduction to Mongodb execution plan and optimizer
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 

Mehr von Ankur Raina (8)

Introduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWIntroduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUW
 
PyMongo for PyCon First Draft
PyMongo for PyCon First DraftPyMongo for PyCon First Draft
PyMongo for PyCon First Draft
 
Ankur py mongo.pptx
Ankur py mongo.pptxAnkur py mongo.pptx
Ankur py mongo.pptx
 
E
EE
E
 
Oracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur RainaOracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur Raina
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Sql project presentation
Sql project presentationSql project presentation
Sql project presentation
 
Big data
Big dataBig data
Big data
 

KĂŒrzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

KĂŒrzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Mug17 gurgaon

  • 2.
  • 4. Performance Tuning vs Optimizing ‱ Optimizing – Opportunity to restructure your application, data model, and queries ‱ Performance Tuning – Experiment and modify system
  • 5. Hardware CPU / RAM / HDD / OS Topology / Network / Hosting Application Input - sources of write traffic Output - sources of query load Schema MongoDB Replica-set configuration, tags, read & write concern Shard configuration, tags, shard keys Where to Focus?
  • 7. Log files, Profiler, Query Optimizer mongod log file profiler (collection) query engine
  • 9. Explain Levels in MongoDB 3.x ‱ queryPlanner (default level): runs the query planner and chooses the winning plan without actually executing the query – Use case: "Which plan will MongoDB choose to run my query?" ‱ executionStats – runs the query optimizer, then runs the winning plan to completion – Use case: "How is my query performing?" ‱ allPlansExecution – same as executionStats, but returns all the query plans, not just the winning plan. – Use case: "I want as much information as possible to diagnose a slow query."
  • 10. db.employees.findOne() { "_id" : ObjectId("592bebaa7761b028cdec1b6f"), "last_name" : "Pham", "quote" : "Aliquam est reiciendis alias neque ad.", "job" : "Counselling psychologist", "ssn" : "401-31-6615", "address" : { "city" : "Lake Meaganton", "state" : "Idaho", "street" : "83248 Woods Extension", "zip" : "10914-3394" }, "first_name" : "Yvonne", "company_id" : ObjectId("58bdbe32500b1d42c7e10be7"), "employer" : "Terry and Sons", "birthday" : ISODate("2011-04-17T21:19:28Z"), "email" : "murillobrian@cox.net" } db.employees.count() 1010893 db.employees.getIndexes() [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "MUGDB.employees" } ]
  • 11. QUERY: db.employees.find({"first_name":"Yvonne"}).sort({"last_name":1}) 2017-05-29T09:54:07.829+0000 I COMMAND [conn286] command MUGDB.employees appName: "MongoDB Shell" command: find { find: "employees", filter: { first_name: "Yvonne" }, sort: { last_name: 1.0 } } planSummary: COLLSCAN cursorid:69354336473 keysExamined:0 docsExamined:1010893 hasSortStage:1 numYields:7900 nreturned:101 reslen:39605 locks:{ Global: { acquireCount: { r: 15802 } }, Database: { acquireCount: { r: 7901 } }, Collection: { acquireCount: { r: 7901 } } } protocol:op_command 480ms
  • 13. { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "MUGDB.employees", "indexFilterSet" : false, "parsedQuery" : { "first_name" : { "$eq" : "Yvonne" } }, "winningPlan" : { "stage" : "SORT", "sortPattern" : { "last_name" : 1 }, "inputStage" : { "stage" : "SORT_KEY_GENERATOR", "inputStage" : { "stage" : "COLLSCAN", "filter" : { "first_name" : { "$eq" : "Yvonne" } }, "direction" : "forward" } } }, "rejectedPlans" : [ ] },
  • 14. "executionStats" : { "executionSuccess" : true, "nReturned" : 498, "executionTimeMillis" : 480, "totalKeysExamined" : 0, "totalDocsExamined" : 1010893, "executionStages" : { "stage" : "SORT", "nReturned" : 498, "executionTimeMillisEstimate" : 0, "works" : 1011395, "advanced" : 498, "needTime" : 1010896, "needYield" : 0, "saveState" : 7901, "restoreState" : 7901, "isEOF" : 1, "invalidates" : 0, "sortPattern" : { "last_name" : 1 }, "memUsage" : 196424, "memLimit" : 33554432, "inputStage" : { "stage" : "SORT_KEY_GENERATOR", "nReturned" : 498, "executionTimeMillisEstimate" : 0, "works" : 1010896, "advanced" : 498, "needTime" : 1010397, "needYield" : 0, "saveState" : 7901, "restoreState" : 7901, "isEOF" : 1, "invalidates" : 0, "inputStage" : { "stage" : "COLLSCAN", "filter" : { "first_name" : { "$eq" : "Yvonne" } }, "nReturned" : 498, "executionTimeMillisEstimate" : 0, "works" : 1010895, "advanced" : 498, "needTime" : 1010396, "needYield" : 0, "saveState" : 7901, "restoreState" : 7901, "isEOF" : 1, "invalidates" : 0,
  • 15. "allPlansExecution" : [ ] }, "serverInfo" : { "host" : "m312", "port" : 30000, "version" : "3.4.2", "gitVersion" : "3f76e40c105fc223b3e5aac3e20dcd026b83b38b" }, "ok" : 1 }
  • 16. Create Index db.employees.createIndex({"first_name":1, "last_name":1} 2017-05-29T10:05:48.432+0000 I COMMAND [conn286] command MUGDB.$cmd appName: "MongoDB Shell" command: createIndexes { createIndexes: "employees", indexes: [ { key: { first_name: 1.0, last_name: 1.0 }, name: "first_name_1_last_name_1" } ] } numYields:0 reslen:98 locks:{ Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 1, W: 1 } }, Collection: { acquireCount: { w: 1 } }, Metadata: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } } protocol:op_command 4578ms
  • 17. MongoDB Enterprise m312RS:PRIMARY> db.employees.find({"first_name":"Yvonne"}).sort({"last_name":1}).explain(true) { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "MUGDB.employees", "indexFilterSet" : false, "parsedQuery" : { "first_name" : { "$eq" : "Yvonne" } }, "winningPlan" : { "stage" : "FETCH", "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "first_name" : 1, "last_name" : 1 }, "indexName" : "first_name_1_last_name_1", "isMultiKey" : false, "multiKeyPaths" : { "first_name" : [ ], "last_name" : [ ] }, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 2, "direction" : "forward",
  • 18. "indexBounds" : { "first_name" : [ "["Yvonne", "Yvonne"]" ], "last_name" : [ "[MinKey, MaxKey]" ] } } }, "rejectedPlans" : [ ] }, "executionStats" : { "executionSuccess" : true, "nReturned" : 498, "executionTimeMillis" : 7, "totalKeysExamined" : 498, "totalDocsExamined" : 498, "executionStages" : { "stage" : "FETCH", "nReturned" : 498, "executionTimeMillisEstimate" : 0, "works" : 499, "advanced" : 498, "needTime" : 0, "needYield" : 0, "saveState" : 3, "restoreState" : 3, "isEOF" : 1, "invalidates" : 0, "docsExamined" : 498, "alreadyHasObj" : 0, "inputStage" : {
  • 19. "stage" : "IXSCAN", "nReturned" : 498, "executionTimeMillisEstimate" : 0, "works" : 499, "advanced" : 498, "needTime" : 0, "needYield" : 0, "saveState" : 3, "restoreState" : 3, "isEOF" : 1, "invalidates" : 0, "keyPattern" : { "first_name" : 1, "last_name" : 1 }, "indexName" : "first_name_1_last_name_1", "isMultiKey" : false, "multiKeyPaths" : { "first_name" : [ ], "last_name" : [ ] }, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 2, "direction" : "forward", "indexBounds" : { "first_name" : [ "["Yvonne", "Yvonne"]" ], "last_name" : [ "[MinKey, MaxKey]" ] }, "keysExamined" : 498, "seeks" : 1, "dupsTested" : 0, "dupsDropped" : 0, "seenInvalidated" : 0 } }, "allPlansExecution" : [ ] }, "serverInfo" : { "host" : "m312", "port" : 30000, "version" : "3.4.2", "gitVersion" : "3f76e40c105fc223b3e5aac3e20dcd026b83b38b" }, "ok" : 1 }
  • 20. $indexStats db.employees.aggregate( [ { $indexStats: { } } ] ) { "name" : "_id_", "key" : { "_id" : 1 }, "host" : "m312:30000", "accesses" : { "ops" : NumberLong(1), "since" : ISODate("2017-05-29T09:36:42.253Z") } } { "name" : "first_name_1_last_name_1", "key" : { "first_name" : 1, "last_name" : 1 }, "host" : "m312:30000", "accesses" : { "ops" : NumberLong(1), "since" : ISODate("2017-05-29T10:05:43.856Z") } }
  • 21. To Be Continued
 Questions? When? ‱ Next MUG ‱ Focus Point? ‱ Which other performance issues would you like to talk about? What else can I check? MongoDB University Free Courses ( https://university.mongodb.com/ ) ‱ M201: MongoDB Performance ‱ M312: Diagnostics and Debugging