SlideShare a Scribd company logo
Non-Relational DatabasesSan  Francisco  Perl  MongersKristina ChodorowSeptember 3, 2009
Who am I?Software  Engineer  at  10genPerl,  PHP,  Java  drivers
Non-Relational Databases
Scaling
Scaling
Technique #1: literally scale
Technique #1: literally scale(Courtesy of Ask Bjorn Hansen)$3,200$4,000,000x 1250 =
Technique #2: shardnow-yesterdayyesterday-the day beforethe day before-the day before that
Technique #3: master-slave replicationRWWR/W?WR
CassandraDesigned by FacebookDistributed - eventually consistentColumn-oriented
CassandraWrites ALWAYS workTwo types of reads: high performanceguaranteed correctR/W atomic within column family
CassandraRow-oriented: joe, 34, karen, 25, bob, 50Column-oriented:joe, karen, bob, 34, 25, 50
Project VoldemortKey/value storeAutomatic replication/partitioning75 Github forks“It is basically a just a big, distributed, persistent, fault-tolerant hash table.”
Tokyo CabinetAnother key/value storeBlazing fast… theoreticallyLua for server-side scripting
Tokyo CabinetKey/value pairsArray storeIndex-able Hash{  name : “Chris”  age : 27,  DOB :  “January 1”}
CouchDBMaster-Master ReplicationMap/ReduceREST API
CouchDB Futon
MongoDB
MongoDBEase of useScalableDynamic queries - similar “feel” to SQLSpeed of key/value stores (almost)Power of RDBMSs (almost)
The Perl DriverAvailable at Github: www.github.com/mongodb/mongo-perl-driver/Install the Perl driver $ perl Makefile.PL && sudo make installAvailable on CPAN (but old):http://search.cpan.org/~flora/MongoDB-0.01/
Downloading MongoDBwww.mongodb.orgBinaries available for Linux, Mac, Windows, Solaris
Start the DB Server$ mkdir ~/db$$ tar zxvfmongodb-<OS>-1.0.0.tgz$ cdmongodb-<OS>-1.0.0$ bin/mongod --dbpath ~/db
Connecting to the Databaseuse MongoDB;my $connection = MongoDB::Connection->new;my $db = $connection->get_database(‘test’);my $collection = $db->get_collection(‘foo’);
Insertingmy $id = $collection->insert(  {	  title => ‘My first blog post’, 	  author => ‘Joe’, 	  content => ‘Hello, world!’    comments => []  });
MongoDB::OIDan autogenerated primary keymy $id = $collection->insert({whatever});print Dumper($id);--------------------------------------------$VAR1 = bless( { 'value' => '4a9700dba5f9107c5cbc9a9c' }, 'MongoDB::OID' )
Updating$collection->update({_id => $id}, {‘$push’ => {comments => 	{		‘author’ => ‘Fred’,		‘comment’ => ‘Dumb post.”  }}});
…which gives us:print Dumper($collection->find_one());--------------------------------------------{  title : ‘My first blog post’,   author : ‘Joe’,   content : ‘Hello, world!’  comments : [{     ‘author’ : ‘Fred’,     ‘comment’ : ‘Dumb post’  }]}
Magic (not the Perl kind)$gt, $gte, $lt, $lte, $eq, $neq, $exists, $set, $mod, $where, $in, $nin, $inc$push, $pull, $pop, $pushAll, $popAll$c->query({ x => {‘$gt’ => 4}})
Queryingmy $commented_by_fred =     $collection->query({        “comments.author” : “Fred”    });my $commented_by_fred =     $collection->query({        “comments.author” : qr/fred/i    });
$where$collection->find_one({‘$where’ :     ‘this.y == (this.x + this.z)’});Will work:{x => 1, y => 4, z => 3}{x => “hi”, y => “hibye”, z => “bye”}Won’t work:{x => 1, y => 1}
Optimizing  $where$collection->find_one({    ‘name’ => ‘Sally’,    ‘age’ => {‘$gt’ => 18},    ‘$where’ => ‘Array.sort(this.interests)[2] == “volleyball”’});
Speaking of indexing…$collection->ensure_index({“age” => “ascending”});$collection->ensure_index({    “name” => “descending”,    “ts” => “descending”,    “comments.author” => “ascending”});
Cursorsmy $cursor = $coll->query({“foo” => “bar”});my $obj;while (my $obj = $cursor->next) {    ...}my @all = $cursor->all;
Pagingmy $cursor = $coll->query->    sort({ts => -1})->    skip($page_num * $results_per_page)->    limit($results_per_page);my @page = $cursor->all;
Logginginsert/update/remove is fastCapped collectionsSchemaless$inc for counts
Thank you!kristina@10gen.com@kchodorow@mongodbirc.freenode.net#mongodbwww.mongodb.org

More Related Content

ODP
Modern Perl
ODP
Moose - YAPC::NA 2012
ODP
Evolving Software with Moose
PDF
"The worst code I ever wrote"
PDF
Barely Legal Xxx Perl Presentation
PPTX
Troubleshooting Puppet
PDF
JSON and the APInauts
Modern Perl
Moose - YAPC::NA 2012
Evolving Software with Moose
"The worst code I ever wrote"
Barely Legal Xxx Perl Presentation
Troubleshooting Puppet
JSON and the APInauts

What's hot (19)

PDF
Trading with opensource tools, two years later
ZIP
AnyMQ, Hippie, and the real-time web
PPT
Working with databases in Perl
PDF
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
PPTX
Migrating to Puppet 4.0
PPT
Fantom and Tales
PPT
Writing Friendly libraries for CodeIgniter
ODP
NYPHP March 2009 Presentation
PDF
Good Evils In Perl
PDF
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
PDF
Ruby - Uma Introdução
PPTX
PHP Basics and Demo HackU
PDF
PL/Perl - New Features in PostgreSQL 9.0
KEY
An introduction to Ruby
PDF
BASH Variables Part 1: Basic Interpolation
PDF
My Adventures In Objective-C (A Rubyists Perspective)
PDF
Memory Manglement in Raku
PDF
How CPAN Testers helped me improve my module
PDF
extending-php
Trading with opensource tools, two years later
AnyMQ, Hippie, and the real-time web
Working with databases in Perl
Crystal: Fundamentos, objetivos y desafios - Cacic 2019
Migrating to Puppet 4.0
Fantom and Tales
Writing Friendly libraries for CodeIgniter
NYPHP March 2009 Presentation
Good Evils In Perl
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner)
Ruby - Uma Introdução
PHP Basics and Demo HackU
PL/Perl - New Features in PostgreSQL 9.0
An introduction to Ruby
BASH Variables Part 1: Basic Interpolation
My Adventures In Objective-C (A Rubyists Perspective)
Memory Manglement in Raku
How CPAN Testers helped me improve my module
extending-php
Ad

Viewers also liked (8)

PDF
Latinoware
PPT
Micromedia Powerpoint2
PDF
San Francisco Java User Group
PDF
OSCON 2009 Lightning Talk
PPT
Pohnpei 2009 Closing Slideshow
PPTX
Dropping ACID with MongoDB
PDF
Study: The Future of VR, AR and Self-Driving Cars
PDF
Hype vs. Reality: The AI Explainer
Latinoware
Micromedia Powerpoint2
San Francisco Java User Group
OSCON 2009 Lightning Talk
Pohnpei 2009 Closing Slideshow
Dropping ACID with MongoDB
Study: The Future of VR, AR and Self-Driving Cars
Hype vs. Reality: The AI Explainer
Ad

Similar to Non-Relational Databases (20)

PDF
Hacking with ruby2ruby
PDF
Hiveminder - Everything but the Secret Sauce
PDF
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
PDF
PECL Picks - Extensions to make your life better
PDF
Smalltalk on rubinius
PDF
Supercharging WordPress Development in 2018
PDF
Perl 5.10
PDF
DataMapper
PDF
Pecl Picks
KEY
Good Evils In Perl (Yapc Asia)
PDF
PDF
Lightweight Webservices with Sinatra and RestClient
PPTX
Perl basics for pentesters part 2
PDF
Модерни езици за програмиране за JVM (2011)
PDF
Quick Intro To JRuby
KEY
Learning From Ruby (Yapc Asia)
PDF
Ruby 入門 第一次就上手
PDF
What's up with Prototype and script.aculo.us?
PDF
SDPHP - Percona Toolkit (It's Basically Magic)
PDF
Rapid Development with Ruby/JRuby and Rails
Hacking with ruby2ruby
Hiveminder - Everything but the Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
PECL Picks - Extensions to make your life better
Smalltalk on rubinius
Supercharging WordPress Development in 2018
Perl 5.10
DataMapper
Pecl Picks
Good Evils In Perl (Yapc Asia)
Lightweight Webservices with Sinatra and RestClient
Perl basics for pentesters part 2
Модерни езици за програмиране за JVM (2011)
Quick Intro To JRuby
Learning From Ruby (Yapc Asia)
Ruby 入門 第一次就上手
What's up with Prototype and script.aculo.us?
SDPHP - Percona Toolkit (It's Basically Magic)
Rapid Development with Ruby/JRuby and Rails

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
A Presentation on Artificial Intelligence
PDF
cuic standard and advanced reporting.pdf
PDF
Approach and Philosophy of On baking technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
A Presentation on Artificial Intelligence
cuic standard and advanced reporting.pdf
Approach and Philosophy of On baking technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation_ Review paper, used for researhc scholars
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing

Non-Relational Databases