SlideShare uma empresa Scribd logo
1 de 21
open-source, high-performance, document-oriented database Antoine Girbal [email_address]
RDBMS (Oracle, MySQL) New Gen. OLAP (vertica, aster, greenplum) Non-relational Operational Stores (“NoSQL”) RDBMS Helper (MemCache, Application layer) Data Store Analytics
[object Object],[object Object],[object Object],[object Object],NoSQL Really Means:
Horizontally Scalable Architectures no joins no complex transactions +
JSON-style Documents {  hello :   “world”  } 16000000 02 hello00 06000000world00 00 http://bsonspec.org represented as  BSON Just like a light and friendly XML
Flexible “Schemas” In collection db.posts: {author: “mike”, links: 3 , date: "Sun Jul 18 2010 14:40:20 GMT-0700 (PDT)" text: “blah blah”} {author: “eliot”, date: "Sun Jul 18 2010 14:40:22 GMT-0700 (PDT)" text: “Here is MongoDB ...”, views: 10 } Potentially all documents in the same collection
Embedded Document { _id: ObjectId("4d1009c7262bb4b94af1cea4") author_id: “1346”, date: "Sun Jul 18 2010 14:40:20 GMT-0700 (PDT)", title: “my story” text: “once upon a time ...”, tags: [“novel”,”english”], Comments:[ {user_id: 234, text: “awesome dude”}, {user_id: 1235, text: “that made me cry”}] } little need for joins or transactions across documents!
Data Model Normalized: Many tables Row/Column Natural: Collections Documents Just BLOBS Can't scale As fast as BLOBs if well modeled, horizontal scalability Easy to scale (Dynamo), can easily use caching No feature Most regular SQL features (satisfies 90% of users) (too) many PERFORMANCE FEATURES
Features ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Replication master slave slave Using Replica Set: - pool of servers with 1 master - automatic master election and failover - distributed reads (slaveOk) slave Client Client
Sharding client mongos ... mongos mongod ... Shards mongod mongod mongod Config Servers mongod mongod mongod mongod mongod mongod mongod mongod ... For large datasets,  or write heavy system
Support ,[object Object],[object Object],[object Object]
Production Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
New Post > post = {author: "mike", ... date: new Date(), ... text: "my blog post", ... tags: ["mongodb", "intro"]} > db.posts.save(post) > db.posts.findOne() { "_id" : ObjectId("4d2f944103e8fdbb36f6d205"), "author" : "mike", "date" : ISODate("2011-01-14T00:08:49.933Z"), "text" : "my blog post", "tags" : ["mongodb","intro"]}
A Quick Aside ,[object Object],[object Object],[object Object],[object Object],_id
Update > db.posts.update({_id: post._id}, ... { $set: {author: "tony"}}) > c = {author: "eliot", date: new Date(), text: "great post!"} > db.posts.update({_id: post._id}, ... { $push: {comments: c}}) > db.posts.update({_id: post._id}, ... { $inc: {views: 1}})
Querying > db.posts.findOne() { "_id" : ObjectId("4d2f944103e8fdbb36f6d205"), "author" : "tony", "comments" : [ { "author" : "eliot", "date" : ISODate("2011-01-14T00:13:52.463Z"), "text" : "great post!" } ], "date" : ISODate("2011-01-14T00:08:49.933Z"), "tags" : [ "mongodb", "intro" ], "text" : "my blog post", "views" : 1 }
More Querying Find by Author > db.posts.find({author: "tony"}) 10 most recent posts: > db.posts.find().sort({date: -1}).limit(10) Posts since April 1 st : > april_1 = new Date(2010, 3, 1) > db.posts.find({date: {$gt: april_1}}) Adding an index to speed up: > db.posts.ensureIndex({author: 1}) > db.posts.ensureIndex({date: 1})
More Querying Find with regexp: > db.posts.find({text: /post$/}) Find within array: > db.posts.find({tags: "intro"}) > db.posts.ensureIndex({tags: 1}) Find within embedded object: > db.posts.find({"comments.author": "eliot"}) > db.posts.ensureIndex({"comments.author": 1})
More Querying Counting: > db.posts.find().count() > db.posts.find({author: "tony"}).count() Paging: > page = 2 > page_size = 15 > db.post.find().limit(page_size).skip(page * page_size) Advanced operators: $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, $where > db.posts.find({$where: "this.author == 'tony' || this.title == 'foo'"})
Download MongoDB http://www.mongodb.org and let us know what you think @mongodb Current 1.6, soon 1.8

Mais conteúdo relacionado

Mais procurados

5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDBTim Callaghan
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDBMongoDB
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesMongoDB
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleMongoDB
 
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphSocialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphMongoDB
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsMongoDB
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBUwe Printz
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBAlex Bilbie
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopSteven Francia
 
Mongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg SolutionsMongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg SolutionsMetatagg Solutions
 
Fast querying indexing for performance (4)
Fast querying   indexing for performance (4)Fast querying   indexing for performance (4)
Fast querying indexing for performance (4)MongoDB
 
PhpstudyTokyo MongoDB PHP CakePHP
PhpstudyTokyo MongoDB PHP CakePHPPhpstudyTokyo MongoDB PHP CakePHP
PhpstudyTokyo MongoDB PHP CakePHPichikaway
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDBNate Abele
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...MongoDB
 

Mais procurados (20)

Mondodb
MondodbMondodb
Mondodb
 
5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB5 Pitfalls to Avoid with MongoDB
5 Pitfalls to Avoid with MongoDB
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
 
Indexing
IndexingIndexing
Indexing
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
 
MongoDB
MongoDBMongoDB
MongoDB
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
 
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social GraphSocialite, the Open Source Status Feed Part 2: Managing the Social Graph
Socialite, the Open Source Status Feed Part 2: Managing the Social Graph
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and Hadoop
 
Mongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg SolutionsMongo Presentation by Metatagg Solutions
Mongo Presentation by Metatagg Solutions
 
Fast querying indexing for performance (4)
Fast querying   indexing for performance (4)Fast querying   indexing for performance (4)
Fast querying indexing for performance (4)
 
PhpstudyTokyo MongoDB PHP CakePHP
PhpstudyTokyo MongoDB PHP CakePHPPhpstudyTokyo MongoDB PHP CakePHP
PhpstudyTokyo MongoDB PHP CakePHP
 
MongoDB - Ekino PHP
MongoDB - Ekino PHPMongoDB - Ekino PHP
MongoDB - Ekino PHP
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
 

Semelhante a High-performance document database MongoDB explained

MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' MeetupMongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' MeetupMongoDB
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.GeeksLab Odessa
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMike Dirolf
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 
Sorry - How Bieber broke Google Cloud at Spotify
Sorry - How Bieber broke Google Cloud at SpotifySorry - How Bieber broke Google Cloud at Spotify
Sorry - How Bieber broke Google Cloud at SpotifyNeville Li
 
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...NoSQLmatters
 
Mongodb intro
Mongodb introMongodb intro
Mongodb introchristkv
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020Thodoris Bais
 
A Rusty introduction to Apache Arrow and how it applies to a time series dat...
A Rusty introduction to Apache Arrow and how it applies to a  time series dat...A Rusty introduction to Apache Arrow and how it applies to a  time series dat...
A Rusty introduction to Apache Arrow and how it applies to a time series dat...Andrew Lamb
 
Spark SQL Deep Dive @ Melbourne Spark Meetup
Spark SQL Deep Dive @ Melbourne Spark MeetupSpark SQL Deep Dive @ Melbourne Spark Meetup
Spark SQL Deep Dive @ Melbourne Spark MeetupDatabricks
 
Scalding big ADta
Scalding big ADtaScalding big ADta
Scalding big ADtab0ris_1
 
Real-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingReal-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingDatabricks
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongoMichael Bright
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and PythonMike Bright
 
2021 04-20 apache arrow and its impact on the database industry.pptx
2021 04-20  apache arrow and its impact on the database industry.pptx2021 04-20  apache arrow and its impact on the database industry.pptx
2021 04-20 apache arrow and its impact on the database industry.pptxAndrew Lamb
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDBMongoDB
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overviewAmit Juneja
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandrarantav
 
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
 

Semelhante a High-performance document database MongoDB explained (20)

MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' MeetupMongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
MongoDB at the Silicon Valley iPhone and iPad Developers' Meetup
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
Sorry - How Bieber broke Google Cloud at Spotify
Sorry - How Bieber broke Google Cloud at SpotifySorry - How Bieber broke Google Cloud at Spotify
Sorry - How Bieber broke Google Cloud at Spotify
 
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020
 
A Rusty introduction to Apache Arrow and how it applies to a time series dat...
A Rusty introduction to Apache Arrow and how it applies to a  time series dat...A Rusty introduction to Apache Arrow and how it applies to a  time series dat...
A Rusty introduction to Apache Arrow and how it applies to a time series dat...
 
Spark SQL Deep Dive @ Melbourne Spark Meetup
Spark SQL Deep Dive @ Melbourne Spark MeetupSpark SQL Deep Dive @ Melbourne Spark Meetup
Spark SQL Deep Dive @ Melbourne Spark Meetup
 
Scalding big ADta
Scalding big ADtaScalding big ADta
Scalding big ADta
 
Real-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to StreamingReal-Time Spark: From Interactive Queries to Streaming
Real-Time Spark: From Interactive Queries to Streaming
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
 
2021 04-20 apache arrow and its impact on the database industry.pptx
2021 04-20  apache arrow and its impact on the database industry.pptx2021 04-20  apache arrow and its impact on the database industry.pptx
2021 04-20 apache arrow and its impact on the database industry.pptx
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
Elasticsearch an overview
Elasticsearch   an overviewElasticsearch   an overview
Elasticsearch an overview
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandra
 
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!
 

High-performance document database MongoDB explained

  • 1. open-source, high-performance, document-oriented database Antoine Girbal [email_address]
  • 2. RDBMS (Oracle, MySQL) New Gen. OLAP (vertica, aster, greenplum) Non-relational Operational Stores (“NoSQL”) RDBMS Helper (MemCache, Application layer) Data Store Analytics
  • 3.
  • 4. Horizontally Scalable Architectures no joins no complex transactions +
  • 5. JSON-style Documents { hello : “world” } 16000000 02 hello00 06000000world00 00 http://bsonspec.org represented as BSON Just like a light and friendly XML
  • 6. Flexible “Schemas” In collection db.posts: {author: “mike”, links: 3 , date: "Sun Jul 18 2010 14:40:20 GMT-0700 (PDT)" text: “blah blah”} {author: “eliot”, date: "Sun Jul 18 2010 14:40:22 GMT-0700 (PDT)" text: “Here is MongoDB ...”, views: 10 } Potentially all documents in the same collection
  • 7. Embedded Document { _id: ObjectId("4d1009c7262bb4b94af1cea4") author_id: “1346”, date: "Sun Jul 18 2010 14:40:20 GMT-0700 (PDT)", title: “my story” text: “once upon a time ...”, tags: [“novel”,”english”], Comments:[ {user_id: 234, text: “awesome dude”}, {user_id: 1235, text: “that made me cry”}] } little need for joins or transactions across documents!
  • 8. Data Model Normalized: Many tables Row/Column Natural: Collections Documents Just BLOBS Can't scale As fast as BLOBs if well modeled, horizontal scalability Easy to scale (Dynamo), can easily use caching No feature Most regular SQL features (satisfies 90% of users) (too) many PERFORMANCE FEATURES
  • 9.
  • 10. Replication master slave slave Using Replica Set: - pool of servers with 1 master - automatic master election and failover - distributed reads (slaveOk) slave Client Client
  • 11. Sharding client mongos ... mongos mongod ... Shards mongod mongod mongod Config Servers mongod mongod mongod mongod mongod mongod mongod mongod ... For large datasets, or write heavy system
  • 12.
  • 13.
  • 14. New Post > post = {author: "mike", ... date: new Date(), ... text: "my blog post", ... tags: ["mongodb", "intro"]} > db.posts.save(post) > db.posts.findOne() { "_id" : ObjectId("4d2f944103e8fdbb36f6d205"), "author" : "mike", "date" : ISODate("2011-01-14T00:08:49.933Z"), "text" : "my blog post", "tags" : ["mongodb","intro"]}
  • 15.
  • 16. Update > db.posts.update({_id: post._id}, ... { $set: {author: "tony"}}) > c = {author: "eliot", date: new Date(), text: "great post!"} > db.posts.update({_id: post._id}, ... { $push: {comments: c}}) > db.posts.update({_id: post._id}, ... { $inc: {views: 1}})
  • 17. Querying > db.posts.findOne() { "_id" : ObjectId("4d2f944103e8fdbb36f6d205"), "author" : "tony", "comments" : [ { "author" : "eliot", "date" : ISODate("2011-01-14T00:13:52.463Z"), "text" : "great post!" } ], "date" : ISODate("2011-01-14T00:08:49.933Z"), "tags" : [ "mongodb", "intro" ], "text" : "my blog post", "views" : 1 }
  • 18. More Querying Find by Author > db.posts.find({author: "tony"}) 10 most recent posts: > db.posts.find().sort({date: -1}).limit(10) Posts since April 1 st : > april_1 = new Date(2010, 3, 1) > db.posts.find({date: {$gt: april_1}}) Adding an index to speed up: > db.posts.ensureIndex({author: 1}) > db.posts.ensureIndex({date: 1})
  • 19. More Querying Find with regexp: > db.posts.find({text: /post$/}) Find within array: > db.posts.find({tags: "intro"}) > db.posts.ensureIndex({tags: 1}) Find within embedded object: > db.posts.find({"comments.author": "eliot"}) > db.posts.ensureIndex({"comments.author": 1})
  • 20. More Querying Counting: > db.posts.find().count() > db.posts.find({author: "tony"}).count() Paging: > page = 2 > page_size = 15 > db.post.find().limit(page_size).skip(page * page_size) Advanced operators: $gt, $lt, $gte, $lte, $ne, $all, $in, $nin, $where > db.posts.find({$where: "this.author == 'tony' || this.title == 'foo'"})
  • 21. Download MongoDB http://www.mongodb.org and let us know what you think @mongodb Current 1.6, soon 1.8

Notas do Editor

  1. Collection (logical groupings of documents) Indexes are per-collection
  2. blog post twitter