SlideShare a Scribd company logo
open-source, high-performance,
schema-free, document-oriented
           database
RDBMS

• Great for many applications
• Shortcomings
 • Scalability
 • Flexibility
CAP Theorem

• Consistency
• Availability
• Tolerance to network Partitions
• Pick two

       http://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf
ACID vs BASE

•   Atomicity
                  •   Basically Available
•   Consistency
                  •   Soft state
•   Isolation
                  •   Eventually consistent
•   Durability
Schema-free

• Loosening constraints - added flexibility
• Dynamically typed languages
• Migrations
BigTable

• Single master node
• Row / Column hybrid
• Versioned
BigTable

• Open-source clones:
 • HBase
 • Hypertable
Dynamo
• Simple Key/Value store
• No master node
 • Write to any (many) nodes
 • Read from one or more nodes (balance
    speed vs. consistency)
• Read repair
Dynamo

• Open-source clones
 • Project Voldemort
 • Cassandra - data model more like
    BigTable
 • Dynomite
memcached

• Used as a caching layer
• Essentially a key/value store
• RAM only - fast
• Does away with ACID
Redis

• Like memcached
• Different
 • Values can be strings, lists, sets
 • Non-volatile
Tokyo Cabinet + Tyrant

• Key/value store with focus on speed
• Some more advanced queries
 • Sorting, range or prefix matching
• Multiple storage engines
 • Hash, B-Tree, Fixed length and Table
• A lot in common with MongoDB:
 • Document-oriented
 • Schema-free
 • JSON-style documents
• Differences
 • MVCC based
 • Replication as path to scalability
 • Query through predefined views
 • ACID
 • REST
• Focus on performance
• Rich dynamic queries
• Secondary indexes
• Replication / failover
• Auto-sharding
• Many platforms / languages supported
MongoDB EuroPython 2009
Good at

• The web
• Caching
• High volume / low value
• Scalability
Less good at

• Highly transactional
• Ad-hoc business intelligence
• Problems that require SQL
PyMongo

• Python driver for MongoDB
• Pure Python, with optional C extension
• Installation (setuptools):
         easy_install pymongo
Document
• Unit of storage (think row)
• Just a dictionary
• Can store many Python types:
 • None, bool, int, float, string / unicode,
    dict, datetime.datetime, compiled re
• Some special types:
 • SON, Binary, ObjectId, DBRef
Collection

• Schema-free equivalent of a table
• Logical groups of documents
• Indexes are per-collection
_id

• Special key
• Present in all documents
• Unique across a Collection
• Any type you want
Blog back-end
Post

{“author”: “mike”,
 “date”: datetime.datetime.utcnow(),
 “text”: “my blog post...”,
 “tags”: [“mongodb”, “python”]}
Comment


{“author”: “eliot”,
 “date”: datetime.datetime.utcnow(),
 “text”: “great post!”}
New post

post = {“author”: “mike”,
        “date”: datetime.datetime.utcnow(),
        “text”: “my blog post...”,
        “tags”: [“mongodb”, “python”]}

post_id = db.posts.save(post)
Embedding a comment

c = {“author”: “eliot”,
     “date”: datetime.datetime.utcnow(),
     “text”: “great post!”}

db.posts.update({“_id”: post_id},
                {“$push”: {“comments”: c}})
Last 10 posts

query = db.posts.find()
          .sort(“date”, DESCENDING)
          .limit(10)

for post in query:
    print post[“text”]
Posts by author


db.posts.find({“author”: “mike”})
Posts in the last week

last_week = datetime.datetime.utcnow() +
            datetime.timedelta(days=-7)

db.posts.find({“date”: {“$gt”: last_week}})
Posts ending with
            ‘Python’


db.posts.find({“text”: re.compile(“Python$”)})
Posts with a tag
  db.posts.find({“tag”: “mongodb”})




            ... and fast
db.posts.create_index(“tag”, ASCENDING)
Counting posts


db.posts.count()

db.posts.find({“author”: “mike”}).count()
Basic paging

page = 2
page_size = 15

db.posts.find().limit(page_size)
               .skip(page * page_size)
Migration: adding titles
  • Easy - just start adding them:
post = {“author”: “mike”,
        “date”: datetime.datetime.utcnow(),
        “text”: “another blog post...”,
        “tags”: [“meetup”, “python”],
        “title”: “Document Oriented Dbs”}

post_id = db.posts.save(post)
Advanced queries

    • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin
    • where()
db.posts.find().where(“this.author == ‘mike’”)

    • group()
Other cool stuff

• Capped collections
• Unique indexes
• Mongo shell
• GridFS
• MongoKit (on pypi)
• Download MongoDB
  http://www.mongodb.org

• Install PyMongo
• Try it out!
• http://www.mongodb.org
• irc.freenode.net#mongodb
• mongodb-user on google groups
• @mongodb, @mdirolf
• mike@10gen.com
• http://www.slideshare.net/mdirolf

More Related Content

What's hot (20)

PPTX
MongoDB
Rony Gregory
 
PDF
TechTalk #14 Grokking: Couchbase - NoSQL + Memcached + Real-time + Offline!
Grokking VN
 
KEY
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Jeremy Zawodny
 
PPTX
Intro To Mongo Db
chriskite
 
PPTX
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
KEY
Introduction to MongoDB (from Austin Code Camp)
Chris Edwards
 
PPTX
MongoDB - Getting Started
Ahmed Helmy
 
PPTX
mongodb-brief-intro-february-2012
Chris Westin
 
KEY
Sphinx at Craigslist in 2012
Jeremy Zawodny
 
PPTX
Why MongoDB over other Databases - Habilelabs
HabileLabs
 
PPTX
Webinar: Building Your First MongoDB App
MongoDB
 
PPTX
Azure Storage Services - Part 01
Neeraj Kumar
 
PDF
CouchDB: replicated data store for distributed proxy server
tkramar
 
PPT
Introduction to mongoDB
Cuelogic Technologies Pvt. Ltd.
 
KEY
MongoDB, E-commerce and Transactions
Steven Francia
 
PPTX
Migrating from MongoDB to Neo4j - Lessons Learned
Nick Manning
 
PPTX
NYT Web Archive
Justin Heideman
 
PPTX
MongoDB basics & Introduction
Jerwin Roy
 
PDF
Grails
Gabriel Dogaru
 
MongoDB
Rony Gregory
 
TechTalk #14 Grokking: Couchbase - NoSQL + Memcached + Real-time + Offline!
Grokking VN
 
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Jeremy Zawodny
 
Intro To Mongo Db
chriskite
 
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
Introduction to MongoDB (from Austin Code Camp)
Chris Edwards
 
MongoDB - Getting Started
Ahmed Helmy
 
mongodb-brief-intro-february-2012
Chris Westin
 
Sphinx at Craigslist in 2012
Jeremy Zawodny
 
Why MongoDB over other Databases - Habilelabs
HabileLabs
 
Webinar: Building Your First MongoDB App
MongoDB
 
Azure Storage Services - Part 01
Neeraj Kumar
 
CouchDB: replicated data store for distributed proxy server
tkramar
 
Introduction to mongoDB
Cuelogic Technologies Pvt. Ltd.
 
MongoDB, E-commerce and Transactions
Steven Francia
 
Migrating from MongoDB to Neo4j - Lessons Learned
Nick Manning
 
NYT Web Archive
Justin Heideman
 
MongoDB basics & Introduction
Jerwin Roy
 

Viewers also liked (19)

PDF
Transfer Printable fabrics Silhouette Cameo 2
Silhouette Cameo 2 Europe
 
PPTX
ไอโซเมอร์
Maruko Supertinger
 
PDF
Mathematics(ME)(Khagendradewangan.blogspot.in)
KHAGENDRA KUMAR DEWANGAN
 
PPT
Fb alopecia in a bulldog
Centro de Dermatología Veterinaria ADERVET
 
PPTX
RECTAS PARALELAS Y PERPENDICULARES
Maria Gabriela Bertozzi Gonzalez
 
DOCX
final resume
Tejas Pawar
 
PPTX
NOSQL - not only sql
Sergey Shishkin
 
PPT
Final report Traditional customs of four seasons_TeodorBalanSchool
Liliana Gheorghian
 
DOCX
Articulo del 42 al 52
PAulo Borikua
 
PPTX
Vittorio Tedeschi aponta motivos para Dicaprio ainda não ter conquistado o Oscar
VittorioTedeschi
 
PPT
Function oveloading
Ritika Sharma
 
PPTX
Workshop 1 susy wootton
Policy Lab
 
PDF
DevOps Boston - Heartbleed at Acquia
Marc Seeger
 
PPT
หลักสูตร Sqs ผจก
Nutthawuth Kanasup
 
PDF
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Glassdoor
 
PDF
PLUG VLAVE - PIN-Layout1
Kristopher Thorpe
 
PDF
รูปพื้นที่ผิว
Krueed Huaybong
 
PDF
2 c0187 mc evaluacion
Unfv Fiis
 
PPTX
CAP and BASE
Dinesh Varadharajan
 
Transfer Printable fabrics Silhouette Cameo 2
Silhouette Cameo 2 Europe
 
ไอโซเมอร์
Maruko Supertinger
 
Mathematics(ME)(Khagendradewangan.blogspot.in)
KHAGENDRA KUMAR DEWANGAN
 
RECTAS PARALELAS Y PERPENDICULARES
Maria Gabriela Bertozzi Gonzalez
 
final resume
Tejas Pawar
 
NOSQL - not only sql
Sergey Shishkin
 
Final report Traditional customs of four seasons_TeodorBalanSchool
Liliana Gheorghian
 
Articulo del 42 al 52
PAulo Borikua
 
Vittorio Tedeschi aponta motivos para Dicaprio ainda não ter conquistado o Oscar
VittorioTedeschi
 
Function oveloading
Ritika Sharma
 
Workshop 1 susy wootton
Policy Lab
 
DevOps Boston - Heartbleed at Acquia
Marc Seeger
 
หลักสูตร Sqs ผจก
Nutthawuth Kanasup
 
Vancouver Rebels of Recruiting Roadshow | Ami Price from ATB Financial
Glassdoor
 
PLUG VLAVE - PIN-Layout1
Kristopher Thorpe
 
รูปพื้นที่ผิว
Krueed Huaybong
 
2 c0187 mc evaluacion
Unfv Fiis
 
CAP and BASE
Dinesh Varadharajan
 
Ad

Similar to MongoDB EuroPython 2009 (20)

KEY
MongoDB NYC Python
Mike Dirolf
 
KEY
MongoDB SF Ruby
Mike Dirolf
 
KEY
MongoDB at ZPUGDC
Mike Dirolf
 
PDF
Introduction to MongoDB
Mike Dirolf
 
PDF
Chris Lea - What does NoSQL Mean for You
Carsonified Team
 
PDF
Mongodb my
Alexey Gaziev
 
PDF
MongoDB
SPBRUBY
 
PDF
Mongo db transcript
foliba
 
PDF
MongoDB: a gentle, friendly overview
Antonio Pintus
 
PDF
MongoDB.pdf
KuldeepKumar778733
 
PPT
9. Document Oriented Databases
Fabio Fumarola
 
PPTX
Drop acid
Mike Feltman
 
PDF
MongoDB Basics
Sarang Shravagi
 
KEY
MongoDB
Steven Francia
 
KEY
Mongodb intro
christkv
 
PDF
Mongo db japan
rogerbodamer
 
KEY
Nosql redis-mongo
ibelmonte
 
KEY
MongoDB - Ruby document store that doesn't rhyme with ouch
Wynn Netherland
 
PPT
Introduction to MongoDB
Ravi Teja
 
MongoDB NYC Python
Mike Dirolf
 
MongoDB SF Ruby
Mike Dirolf
 
MongoDB at ZPUGDC
Mike Dirolf
 
Introduction to MongoDB
Mike Dirolf
 
Chris Lea - What does NoSQL Mean for You
Carsonified Team
 
Mongodb my
Alexey Gaziev
 
MongoDB
SPBRUBY
 
Mongo db transcript
foliba
 
MongoDB: a gentle, friendly overview
Antonio Pintus
 
MongoDB.pdf
KuldeepKumar778733
 
9. Document Oriented Databases
Fabio Fumarola
 
Drop acid
Mike Feltman
 
MongoDB Basics
Sarang Shravagi
 
Mongodb intro
christkv
 
Mongo db japan
rogerbodamer
 
Nosql redis-mongo
ibelmonte
 
MongoDB - Ruby document store that doesn't rhyme with ouch
Wynn Netherland
 
Introduction to MongoDB
Ravi Teja
 
Ad

More from Mike Dirolf (9)

PDF
Indexing
Mike Dirolf
 
PDF
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
KEY
Inside PyMongo - MongoNYC
Mike Dirolf
 
PDF
FrozenRails Training
Mike Dirolf
 
KEY
Python Development (MongoSF)
Mike Dirolf
 
KEY
MongoDB: How it Works
Mike Dirolf
 
KEY
MongoDB hearts Django? (Django NYC)
Mike Dirolf
 
PDF
MongoDB at RubyConf
Mike Dirolf
 
KEY
MongoDB at RubyEnRails 2009
Mike Dirolf
 
Indexing
Mike Dirolf
 
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
Inside PyMongo - MongoNYC
Mike Dirolf
 
FrozenRails Training
Mike Dirolf
 
Python Development (MongoSF)
Mike Dirolf
 
MongoDB: How it Works
Mike Dirolf
 
MongoDB hearts Django? (Django NYC)
Mike Dirolf
 
MongoDB at RubyConf
Mike Dirolf
 
MongoDB at RubyEnRails 2009
Mike Dirolf
 

Recently uploaded (20)

PDF
MiniTool Partition Wizard 12.8 Crack License Key [2025] Free
hashhshs786
 
PDF
Jaymee Shell’s Art Classes: Painting Made Easy for Beginners
Jaymee Shell Painting Class
 
PPTX
Seasonal_Water_Quality_Manasbal_PPT.pptx
himanshu2021bciv125
 
PDF
seminar.pdf...,...........................
contra00725
 
PPTX
Mesagrahjkhkjhggiugfjiyhgkhyvghjvgdxrftw ghfruykfmfgv n.pptxojkk;k.ppt
dy7949748
 
PPTX
Download FL Studio Full Crack With Free Version Latest
josanj305
 
PPTX
Georgian National Ballet _Sukhishvili_.pptx
shyirscc
 
PDF
War and Peace (Annotated: History, Philosophy and Geopolitics)
Nicolae Sfetcu
 
PDF
The Adventures of Syr and Squire - Part 3
MatthewHill208
 
PDF
The Adventures of Syr and Squire - Part 4
MatthewHill208
 
PDF
>Microsoft Office 365 Crack + Product Key Latest 2025
utfefguu
 
PDF
Expert Industrial Model Making Solutions for Your Business.pdf
Maadhu Creatives-Model Making Company
 
PPT
Captain america painting competition -- 18
Su Yan-Jen
 
PDF
The Adventures of Syr and Squire - Part 1
MatthewHill208
 
PDF
adolf-loos-ornamento-y-delito.pdf aaaaaaaaaaaaaaaaaa
TatianaYaez1
 
PPTX
Congolese Doll Making a KS2 School resource
Cartwheel Arts
 
PDF
AI security AI security AI securityAI security AI security
elite44
 
PPTX
新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组
sonyakaslana
 
PPTX
Indian 'Diyah' Making a KS2 School resource
Cartwheel Arts
 
PPTX
加拿大学位证(Capilano毕业证书)卡普兰诺学院毕业证书如何办理
Taqyea
 
MiniTool Partition Wizard 12.8 Crack License Key [2025] Free
hashhshs786
 
Jaymee Shell’s Art Classes: Painting Made Easy for Beginners
Jaymee Shell Painting Class
 
Seasonal_Water_Quality_Manasbal_PPT.pptx
himanshu2021bciv125
 
seminar.pdf...,...........................
contra00725
 
Mesagrahjkhkjhggiugfjiyhgkhyvghjvgdxrftw ghfruykfmfgv n.pptxojkk;k.ppt
dy7949748
 
Download FL Studio Full Crack With Free Version Latest
josanj305
 
Georgian National Ballet _Sukhishvili_.pptx
shyirscc
 
War and Peace (Annotated: History, Philosophy and Geopolitics)
Nicolae Sfetcu
 
The Adventures of Syr and Squire - Part 3
MatthewHill208
 
The Adventures of Syr and Squire - Part 4
MatthewHill208
 
>Microsoft Office 365 Crack + Product Key Latest 2025
utfefguu
 
Expert Industrial Model Making Solutions for Your Business.pdf
Maadhu Creatives-Model Making Company
 
Captain america painting competition -- 18
Su Yan-Jen
 
The Adventures of Syr and Squire - Part 1
MatthewHill208
 
adolf-loos-ornamento-y-delito.pdf aaaaaaaaaaaaaaaaaa
TatianaYaez1
 
Congolese Doll Making a KS2 School resource
Cartwheel Arts
 
AI security AI security AI securityAI security AI security
elite44
 
新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组 新媒体营销第一组
sonyakaslana
 
Indian 'Diyah' Making a KS2 School resource
Cartwheel Arts
 
加拿大学位证(Capilano毕业证书)卡普兰诺学院毕业证书如何办理
Taqyea
 

MongoDB EuroPython 2009