SlideShare a Scribd company logo
MongoDB
Introduction and Internal
by
Shridhar Joshi
What is MongoDB?
Open source, scalable, high-performance, document-oriented NoSQL Key-Value
ased database.
Features
•
JSON-style document –oriented storage with schema-less
•
B-tree index supported on any attribute
•
Log-based replication for Master/Slave and Replica Set
•
Auto-sharding architecture (via horizontal partition) scales to thousands of no
•
NoSQL-style query
•
Surprising updating behaviors
•
Map/Reduce support
•
GridFS specification for storing large files
•
Developed by 10gen with commercial support
Well/Less Well Suited
Source: http://www.mongodb.org/display/DOCS/Use+Cases
Basic concepts in MongoDB
NoSQL MongoDB
Database
Collection
Document
Field
Index
Cursor
Relational DBMS
Database
Relation
Tuple
Column
Index
Cursor
MongoDB
Databases*
Collections*
Documents* Indexes*
Fields*
* means 0 or more objects
Relational DBMS
Databases*
Relations*
Columns* Indexes*
Each document has its own fields
and makes MongoDB schema-
less.
CRUD Demo time
Ø
show dbs view existing databases
Ø
use test use database “test”
Ø
db.t.insert({name:’bob’,age:’30’}) insert 30 years bob
Ø
db. t.insert({name:’alice’,gender:’female’}) insert lady alice
Ø
db. t.find() list all documents in
collection t
Ø
db. t.find({name:’bob’},{age:1}) find 1 year old bob
Ø
db. t.find().limit(1).skip(1) find the second document
Ø
db. t.find().sort({name:1}) sort the results with ascend
name
Ø
db. t.find({$or:[{name:’bob’},{name:’tom’}]}) find bob or tom’s documents
Ø
db. t.update({name:’ bob’},{$set:{age:31}}, update all bob’s age to 31
Ø
false,true})
Ø
db.stats() database statistic
Ø
db.getCollectionNames() collections under this db
Ø
db.t.ensureIndex({name:1}) create index on name
Ø
db.people.find({name:“bob"}).explain() explain plan step
Query Optimization
db.people.find({x:10,y:”foo”})
Index on x
Index on y
Collection people
Index Scan
Index Scan
DiskLocation Scan
MongoDB Architecture
Source: mongoDB Replication and Replica Set by Dwight Merriman 10gen
MongoDB Sharding
ongoDB uses two key operations to facilitate sharding - split and migrate.
plit splits a chunk into two ranges; it is done to assure no one chunk is unusually la
igrate moves a chunk (the data associated with a key range) to another shard.
his is done as needed to rebalance.
plit is an inexpensive metadata operation, while migrate is expensive as large amo
data may be moving server to server.
oth splits and migrates are performed automatically.
ongoDB has a sub-system called Balancer, which monitors shards loads and move
hunks around if it finds an imbalance.
you add a new shard to the system, some chunks will eventually be moved to
at shard to spread out the load.
recently split chunk may be moved immediately to a new shard if the system
edicts that future insertions will benefit from that move.
MongoDB
Sharding
Pull mode
MongoDB Sharding: Briefly
FROM:C TO:N
#Copy Index Definition from C
#Remove existing data in [min~max]
#Clone the data in[min~max] from C
#Ask C to replicate the changes
#Make sure my view is complete and lock
#Get the document’s DiskLoc for sharding
#Trigger the N to sharding in Pull mode
Sequence
#N commit
#Ask N to commit
MongoDB Sharding: In Details
FROM TO
Notice: The FROM can be updated/deleted during sharding and TO can catch up in
step 4.
Replication and Sharding
Source:
MongoDB Replication: Pull mode
Slave continuously pull the OpLog from Master.
Question
Reference:
1: Source code digest: http://www.cnblogs.com/daizhj/category/260889.html
2: Books http://www.mongodb.org/display/DOCS/Books
3: MongoDB offical website http://www.mongodb.com/

More Related Content

PPTX
Klevis Mino: MongoDB
PPTX
Log MongoDB slow query
PPTX
Introduction to MongoDB
KEY
MongoDB NYC Python
PPTX
Understanding and tuning WiredTiger, the new high performance database engine...
PDF
Mongo db3.0 wired_tiger_storage_engine
PPTX
Back to Basics 2017: Introduction to Sharding
PPTX
MongoDB
Klevis Mino: MongoDB
Log MongoDB slow query
Introduction to MongoDB
MongoDB NYC Python
Understanding and tuning WiredTiger, the new high performance database engine...
Mongo db3.0 wired_tiger_storage_engine
Back to Basics 2017: Introduction to Sharding
MongoDB

What's hot (20)

PPT
MongoDb - Details on the POC
PPT
Introduction to MongoDB
PDF
Updating materialized views and caches using kafka
PPTX
Using MongoDB For BigData in 20 Minutes
PDF
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
PPTX
MongoDB
PPTX
Why Your MongoDB Needs Redis
PPTX
Dev Jumpstart: Build Your First App with MongoDB
PPTX
File uploads to s3
PPTX
Mongodb basics and architecture
PPTX
PPTX
MongoDB for Spatio-Behavioral Data Analysis and Visualization
PDF
MongoDB World 2016: Poster Sessions eBook
KEY
2011 mongo sf-scaling
PDF
Replicating application data into materialized views
PPTX
Intro To Mongo Db
PPTX
Monogo db in-action
PPTX
From MySQL to MongoDB at Wordnik (Tony Tam)
PPTX
Cassandra Lunch #59 Functions in Cassandra
PDF
Alluxio Data Orchestration Platform for the Cloud
MongoDb - Details on the POC
Introduction to MongoDB
Updating materialized views and caches using kafka
Using MongoDB For BigData in 20 Minutes
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
MongoDB
Why Your MongoDB Needs Redis
Dev Jumpstart: Build Your First App with MongoDB
File uploads to s3
Mongodb basics and architecture
MongoDB for Spatio-Behavioral Data Analysis and Visualization
MongoDB World 2016: Poster Sessions eBook
2011 mongo sf-scaling
Replicating application data into materialized views
Intro To Mongo Db
Monogo db in-action
From MySQL to MongoDB at Wordnik (Tony Tam)
Cassandra Lunch #59 Functions in Cassandra
Alluxio Data Orchestration Platform for the Cloud
Ad

Similar to Mongo presentation conf (20)

PPTX
DBVersity MongoDB Online Training Presentations
PDF
Mongodb
PDF
MongoDB - An Introduction
PPTX
MongoDB_ppt.pptx
PPT
Introduction to Mongodb
PPTX
Mongodb introduction and_internal(simple)
PPTX
MongoDB - A next-generation database that lets you create applications never ...
PDF
Introduction to mongo db
KEY
The Care + Feeding of a Mongodb Cluster
PPTX
MongoDB is a document database. It stores data in a type of JSON format calle...
PDF
Evolution of MonogDB Sharding and Its Best Practices - Ranjith A - Mydbops Team
PPTX
Introduction to Sharding
PPTX
MongoDB: An Introduction - june-2011
PPTX
Introduction to MongoDB.pptx
PPTX
PPTX
MongoDB - An Introduction
PDF
Introduction to MongoDB
PPTX
MongoDB presentation
PPTX
mongo.pptx
PDF
MongoDB Interview Questions PDF By ScholarHat
DBVersity MongoDB Online Training Presentations
Mongodb
MongoDB - An Introduction
MongoDB_ppt.pptx
Introduction to Mongodb
Mongodb introduction and_internal(simple)
MongoDB - A next-generation database that lets you create applications never ...
Introduction to mongo db
The Care + Feeding of a Mongodb Cluster
MongoDB is a document database. It stores data in a type of JSON format calle...
Evolution of MonogDB Sharding and Its Best Practices - Ranjith A - Mydbops Team
Introduction to Sharding
MongoDB: An Introduction - june-2011
Introduction to MongoDB.pptx
MongoDB - An Introduction
Introduction to MongoDB
MongoDB presentation
mongo.pptx
MongoDB Interview Questions PDF By ScholarHat
Ad

Recently uploaded (20)

PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Hybrid model detection and classification of lung cancer
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Mushroom cultivation and it's methods.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Approach and Philosophy of On baking technology
PDF
A comparative analysis of optical character recognition models for extracting...
OMC Textile Division Presentation 2021.pptx
Hybrid model detection and classification of lung cancer
Chapter 5: Probability Theory and Statistics
Accuracy of neural networks in brain wave diagnosis of schizophrenia
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Heart disease approach using modified random forest and particle swarm optimi...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
A Presentation on Artificial Intelligence
Hindi spoken digit analysis for native and non-native speakers
1 - Historical Antecedents, Social Consideration.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Zenith AI: Advanced Artificial Intelligence
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Mushroom cultivation and it's methods.pdf
1. Introduction to Computer Programming.pptx
Approach and Philosophy of On baking technology
A comparative analysis of optical character recognition models for extracting...

Mongo presentation conf

  • 2. What is MongoDB? Open source, scalable, high-performance, document-oriented NoSQL Key-Value ased database. Features • JSON-style document –oriented storage with schema-less • B-tree index supported on any attribute • Log-based replication for Master/Slave and Replica Set • Auto-sharding architecture (via horizontal partition) scales to thousands of no • NoSQL-style query • Surprising updating behaviors • Map/Reduce support • GridFS specification for storing large files • Developed by 10gen with commercial support
  • 3. Well/Less Well Suited Source: http://www.mongodb.org/display/DOCS/Use+Cases
  • 4. Basic concepts in MongoDB NoSQL MongoDB Database Collection Document Field Index Cursor Relational DBMS Database Relation Tuple Column Index Cursor MongoDB Databases* Collections* Documents* Indexes* Fields* * means 0 or more objects Relational DBMS Databases* Relations* Columns* Indexes* Each document has its own fields and makes MongoDB schema- less.
  • 5. CRUD Demo time Ø show dbs view existing databases Ø use test use database “test” Ø db.t.insert({name:’bob’,age:’30’}) insert 30 years bob Ø db. t.insert({name:’alice’,gender:’female’}) insert lady alice Ø db. t.find() list all documents in collection t Ø db. t.find({name:’bob’},{age:1}) find 1 year old bob Ø db. t.find().limit(1).skip(1) find the second document Ø db. t.find().sort({name:1}) sort the results with ascend name Ø db. t.find({$or:[{name:’bob’},{name:’tom’}]}) find bob or tom’s documents Ø db. t.update({name:’ bob’},{$set:{age:31}}, update all bob’s age to 31 Ø false,true}) Ø db.stats() database statistic Ø db.getCollectionNames() collections under this db Ø db.t.ensureIndex({name:1}) create index on name Ø db.people.find({name:“bob"}).explain() explain plan step
  • 6. Query Optimization db.people.find({x:10,y:”foo”}) Index on x Index on y Collection people Index Scan Index Scan DiskLocation Scan
  • 7. MongoDB Architecture Source: mongoDB Replication and Replica Set by Dwight Merriman 10gen
  • 8. MongoDB Sharding ongoDB uses two key operations to facilitate sharding - split and migrate. plit splits a chunk into two ranges; it is done to assure no one chunk is unusually la igrate moves a chunk (the data associated with a key range) to another shard. his is done as needed to rebalance. plit is an inexpensive metadata operation, while migrate is expensive as large amo data may be moving server to server. oth splits and migrates are performed automatically. ongoDB has a sub-system called Balancer, which monitors shards loads and move hunks around if it finds an imbalance. you add a new shard to the system, some chunks will eventually be moved to at shard to spread out the load. recently split chunk may be moved immediately to a new shard if the system edicts that future insertions will benefit from that move.
  • 10. MongoDB Sharding: Briefly FROM:C TO:N #Copy Index Definition from C #Remove existing data in [min~max] #Clone the data in[min~max] from C #Ask C to replicate the changes #Make sure my view is complete and lock #Get the document’s DiskLoc for sharding #Trigger the N to sharding in Pull mode Sequence #N commit #Ask N to commit
  • 11. MongoDB Sharding: In Details FROM TO Notice: The FROM can be updated/deleted during sharding and TO can catch up in step 4.
  • 13. MongoDB Replication: Pull mode Slave continuously pull the OpLog from Master.
  • 14. Question Reference: 1: Source code digest: http://www.cnblogs.com/daizhj/category/260889.html 2: Books http://www.mongodb.org/display/DOCS/Books 3: MongoDB offical website http://www.mongodb.com/