SlideShare a Scribd company logo
Mongo db 2.2 aggregation like a champ
Map/Reduce pain
Aggregation framework
- Concepts
- Code demo

...Whatever comes our way
Documents



                                    Emit (0..* )




                                                   Reduce

•   One chance at transform
•   Good for large IO
•   In/Out of Javascript costly
•   Imparts "non-interactiveness"   Finalize

•   All I wanted was a group-by!
{ "_id" : "silver", "score" : 17, "house" : "A" }


db.scores.aggregate({$group:
   {_id:"$house", avg:{$avg:"$score"}}});

    {
     "result":[
     {"_id" : "B","avg" : 20.333333333333332},
     {"_id" : "A","avg" : 19.333333333333332}
     ],
     "ok":1
    }
Pipeline
           Operators ("stage")
Collectors, Transformers (operator type)
 Expressions ("transform“,”evaluate”)
All docs*
                                                     One at a time*
                                                      "The" => "A"

Documents




            operator   operator                     operator




                             * not really, not always, it depends, kinda.
$group
                               $match
                                $limit
                                 $skip
                              $project
                              $unwind
                                 $sort
$group is why we are here..
but need not be last stage
$group
  In: doc, Out: aggregated by _id specified

$project
  In: doc, Out: new doc, shaped to your liking

$unwind
  In: array, Out: same doc + 1 array element
Mongo db 2.2 aggregation like a champ
Download - mongodb.org v 2.2

Ask – 10gen, Google groups, IRC (people use
  them)

Consult / Train - nuri@plusnconsulting.com

More Related Content

PDF
JavaScript Objects
PDF
Javascript jQuery jQuery Ui
PPTX
Functions and Objects in JavaScript
KEY
PDF
Learning jQuery in 30 minutes
PPTX
Java script
PPTX
J query1
PPT
J query
JavaScript Objects
Javascript jQuery jQuery Ui
Functions and Objects in JavaScript
Learning jQuery in 30 minutes
Java script
J query1
J query

What's hot (20)

PPTX
Object oriented javascript
PDF
djangocon dajaxproject lightning talk
PDF
Mongoskin - Guilin
PDF
Prototype & jQuery
PPTX
PostgreSQL's Secret NoSQL Superpowers
PDF
Desarrollo de módulos en Drupal e integración con dispositivos móviles
PPT
A Short Introduction To jQuery
PPT
JQuery introduction
PPTX
JQuery Presentation
PDF
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
PDF
Trimming The Cruft
PDF
Designing a JavaFX Mobile application
PDF
Productive Programming in Groovy
PDF
The jQuery Divide
PPTX
Closure
PPTX
Building High Perf Web Apps - IE8 Firestarter
PDF
Performance Optimization and JavaScript Best Practices
PDF
ScalikeJDBC Tutorial for Beginners
PDF
Aggregation Framework MongoDB Days Munich
PDF
Testing Web Applications with GEB
Object oriented javascript
djangocon dajaxproject lightning talk
Mongoskin - Guilin
Prototype & jQuery
PostgreSQL's Secret NoSQL Superpowers
Desarrollo de módulos en Drupal e integración con dispositivos móviles
A Short Introduction To jQuery
JQuery introduction
JQuery Presentation
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
Trimming The Cruft
Designing a JavaFX Mobile application
Productive Programming in Groovy
The jQuery Divide
Closure
Building High Perf Web Apps - IE8 Firestarter
Performance Optimization and JavaScript Best Practices
ScalikeJDBC Tutorial for Beginners
Aggregation Framework MongoDB Days Munich
Testing Web Applications with GEB
Ad

Viewers also liked (20)

PPTX
Docker Container Lifecycles, Problem or Opportunity? by Baruch Sadogursky, JFrog
PPTX
Портал и отчетность для руководства - Как сделать бизнес прозрачным
PPTX
Successfully speaking
PPTX
Population Census Web Access System
PDF
20120428 ニコニコ学会β スケルトニクス製作委員会
PDF
ICFF 2015 BOOTH PHOTOS
PDF
Прогноз ССВ
PPTX
Queue in the cloud with mongo db
PDF
Fortina Installations
PPTX
NCVPS: Real Life Educational Technology
PPT
Ncvps comp 380
PPTX
What is social
PPTX
Social media
PDF
Fortina Installations
PPT
NCVPS Comp 380
PPT
Ncvps comp 380
PDF
Ebook corel draw x3 lengkap
PDF
20121124 ロボコニストカンファ・リトライ 外骨格スーツの創り方01
DOCX
51358205 project-on-international-business
PPTX
Управление ключевыми показателями деятельности (KPI) - от идеи до воплощения
Docker Container Lifecycles, Problem or Opportunity? by Baruch Sadogursky, JFrog
Портал и отчетность для руководства - Как сделать бизнес прозрачным
Successfully speaking
Population Census Web Access System
20120428 ニコニコ学会β スケルトニクス製作委員会
ICFF 2015 BOOTH PHOTOS
Прогноз ССВ
Queue in the cloud with mongo db
Fortina Installations
NCVPS: Real Life Educational Technology
Ncvps comp 380
What is social
Social media
Fortina Installations
NCVPS Comp 380
Ncvps comp 380
Ebook corel draw x3 lengkap
20121124 ロボコニストカンファ・リトライ 外骨格スーツの創り方01
51358205 project-on-international-business
Управление ключевыми показателями деятельности (KPI) - от идеи до воплощения
Ad

Similar to Mongo db 2.2 aggregation like a champ (20)

KEY
MongoDB Aggregation Framework
PDF
MongoDB Aggregation Framework
PDF
Experiment no 05
PPTX
MongoDB's New Aggregation framework
PPTX
mongodb-aggregation-may-2012
ODP
Aggregation Framework in MongoDB Overview Part-1
PDF
De normalised london aggregation framework overview
PPTX
Aggregation Framework
PPTX
The Aggregation Framework
PDF
Full metal mongo
PDF
Data Engineering: Arrays in Mongo DB(and operators)
PDF
Precog & MongoDB User Group: Skyrocket Your Analytics
PPTX
Joins and Other MongoDB 3.2 Aggregation Enhancements
PPTX
Aggregation Presentation for databses (1).pptx
PDF
MongoDB, Hadoop and humongous data - MongoSV 2012
PDF
Latinoware
PDF
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
PDF
Mdb dn 2017_18_query_hackathon
PPTX
MongoDB Aggregation MongoSF May 2011
PDF
Why couchdb is cool
MongoDB Aggregation Framework
MongoDB Aggregation Framework
Experiment no 05
MongoDB's New Aggregation framework
mongodb-aggregation-may-2012
Aggregation Framework in MongoDB Overview Part-1
De normalised london aggregation framework overview
Aggregation Framework
The Aggregation Framework
Full metal mongo
Data Engineering: Arrays in Mongo DB(and operators)
Precog & MongoDB User Group: Skyrocket Your Analytics
Joins and Other MongoDB 3.2 Aggregation Enhancements
Aggregation Presentation for databses (1).pptx
MongoDB, Hadoop and humongous data - MongoSV 2012
Latinoware
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Mdb dn 2017_18_query_hackathon
MongoDB Aggregation MongoSF May 2011
Why couchdb is cool

Recently uploaded (20)

PDF
Dominate Her Mind – Make Women Chase, Lust, & Submit
PPTX
A portfolio Template for Interior Designer
PDF
Quiet Wins: Why the Silent Fish Survives.pdf
PDF
Anxiety Awareness Journal One Week Preview
PDF
⚡ Prepping for grid failure_ 6 Must-Haves to Survive Blackout!.pdf
PPTX
Life Skills Education - Introduction - 1
DOCX
Paulo Tuynmam: Nine Timeless Anchors of Authentic Leadership
PDF
Lesson 4 Education for Better Work. Evaluate your training options.
PDF
PLAYLISTS DEI MEGAMIX E DEEJAY PARADE DAL 1991 AL 2004 SU RADIO DEEJAY
PPTX
My future self called today–I answered.pptx
PPTX
Modulation is the process of varying one or more properties of a carrier sign...
PDF
Want to Fly Like an Eagle - Leave the Chickens Behind.pdf
PPT
Lesson From Geese! Understanding Teamwork
PDF
relational self of self improvements etc
DOCX
Boost your energy levels and Shred Weight
PPTX
UNIVERSAL HUMAN VALUES for NEP student .pptx
PPTX
Commmunication in Todays world- Principles and Barriers
PDF
technical writing on emotional quotient ppt
PDF
How Long Does It Take to Quit Vaping.pdf
PPTX
Hazards-of-Uncleanliness-Protecting-Your-Health.pptx
Dominate Her Mind – Make Women Chase, Lust, & Submit
A portfolio Template for Interior Designer
Quiet Wins: Why the Silent Fish Survives.pdf
Anxiety Awareness Journal One Week Preview
⚡ Prepping for grid failure_ 6 Must-Haves to Survive Blackout!.pdf
Life Skills Education - Introduction - 1
Paulo Tuynmam: Nine Timeless Anchors of Authentic Leadership
Lesson 4 Education for Better Work. Evaluate your training options.
PLAYLISTS DEI MEGAMIX E DEEJAY PARADE DAL 1991 AL 2004 SU RADIO DEEJAY
My future self called today–I answered.pptx
Modulation is the process of varying one or more properties of a carrier sign...
Want to Fly Like an Eagle - Leave the Chickens Behind.pdf
Lesson From Geese! Understanding Teamwork
relational self of self improvements etc
Boost your energy levels and Shred Weight
UNIVERSAL HUMAN VALUES for NEP student .pptx
Commmunication in Todays world- Principles and Barriers
technical writing on emotional quotient ppt
How Long Does It Take to Quit Vaping.pdf
Hazards-of-Uncleanliness-Protecting-Your-Health.pptx

Mongo db 2.2 aggregation like a champ

  • 2. Map/Reduce pain Aggregation framework - Concepts - Code demo ...Whatever comes our way
  • 3. Documents Emit (0..* ) Reduce • One chance at transform • Good for large IO • In/Out of Javascript costly • Imparts "non-interactiveness" Finalize • All I wanted was a group-by!
  • 4. { "_id" : "silver", "score" : 17, "house" : "A" } db.scores.aggregate({$group: {_id:"$house", avg:{$avg:"$score"}}}); { "result":[ {"_id" : "B","avg" : 20.333333333333332}, {"_id" : "A","avg" : 19.333333333333332} ], "ok":1 }
  • 5. Pipeline Operators ("stage") Collectors, Transformers (operator type) Expressions ("transform“,”evaluate”)
  • 6. All docs* One at a time* "The" => "A" Documents operator operator operator * not really, not always, it depends, kinda.
  • 7. $group $match $limit $skip $project $unwind $sort $group is why we are here.. but need not be last stage
  • 8. $group In: doc, Out: aggregated by _id specified $project In: doc, Out: new doc, shaped to your liking $unwind In: array, Out: same doc + 1 array element
  • 10. Download - mongodb.org v 2.2 Ask – 10gen, Google groups, IRC (people use them) Consult / Train - nuri@plusnconsulting.com