1 / 8

MongoDB Essentials II

what you need to know to get cranking. MongoDB Essentials II. Querying Subset Arrays Indexing Aggregating – map-reduce. What you will learn. Retrieve only what you need Structure remains same (not full projection) Syntax { a:” hello ”, b:” hola ”, c :”bonjour ”, _ id:1}

livi
Télécharger la présentation

MongoDB Essentials II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. what you need to know to get cranking MongoDB Essentials II

  2. Querying • Subset • Arrays • Indexing • Aggregating – map-reduce What you will learn

  3. Retrieve only what you need • Structure remains same (not full projection) • Syntax {a:”hello”, b:”hola”, c:”bonjour”, _id:1} • db.people.find({},{b:0}) • db.people.find({},{a:1,c:1}) • db.people.find({},{a:1,_id:0}) Selecting

  4. Look like an JS array (BSON actually) • Are stores as a document with index as key • Syntax • db.people.find({“pets.name”:”Felix”}) • db.people.find({},{pets[0]:1}) • db.people.find({},{pets:{$slice:1}}) • db.people.find({},{pets:{$slice:[-2,1]}}) Arrays

  5. Indexes run deep. • Arrays can be indexed – (try that with RDBMS!) • Every collection has _id indexed. (“Clustered”) • Index structure is Btree • Covered index support (except array) • Syntax • db.people.ensureIndex({“pets.type”:1}) • db.people.ensureIndex({birthdate:-1}) • db.system.indexes.find() Indexed access

  6. The only way to aggregate* • Challenge: lots of IO to read all records • Answer: distribute aggregation to nodes, then cull the results • Implementation: Map Reduce Map/Reduce

  7. Map • function() • At some point: emit(key, value) • Value can be scalar or any object • Reduce • function(key, values) • return some computation over the values (typically). Key is implied. • Finalize • function(key, value) • Optional. Re-shape/filter - final step in computation. • Output • Screen, into new or existing collection (incremental) • Query • Limit work, support incremental m/r. Map/Reduce

  8. http://openmymind.net/mongodb.pdf • http://mongodb.org/ • http://10gen.com/ • http://plusnconsulting.com/ • nuri@plusnconsulting.com • (818) 446.NUHA References

More Related