One of the most common questions I see about MongoDB schema design is: I have a collection of blog posts and each post has an array of comments. How do I get… …all comments by a given author …the most recent comments …the most popular commenters? And so on. The answer to this has alwaysContinue reading “The Comments Conundrum”
Category Archives: MongoDB
Hacking Chess: Data Munging
This is a supplement to the Hacking Chess with the MongoDB Pipeline. This post has instructions for rolling your own data sets from chess games. Download a collection of chess games you like. I’m using 1132 wins in less than 10 moves, but any of them should work. These files are in a format calledContinue reading “Hacking Chess: Data Munging”
Hacking Chess with the MongoDB Pipeline
MongoDB’s new aggegation framework is now available in the nightly build! This post demonstrates some of its capabilities by using it to analyze chess games. Make sure you have a the “Development Release (Unstable)” nightly running before trying out the stuff in this post. The aggregation framework will be in 2.1.0, but as of thisContinue reading “Hacking Chess with the MongoDB Pipeline”
Replica Set Internals Bootcamp: Part I – Elections
I’ve been doing replica set “bootcamps” for new hires. It’s mainly focused on applying this to debug replica set issues and being able to talk fluently about what’s happening, but it occurred to me that you (blog readers) might be interested in it, too. There are 8 subjects I cover in my bootcamp: Elections CreatingContinue reading “Replica Set Internals Bootcamp: Part I – Elections”
Popping Timestamps into ObjectIds
ObjectIds contain a timestamp, which tells you when the document was created. Because the _id field is always indexed, that means you have a “free” index on your “created at” time (unless you have persnickety requirements for creation times, like resolutions of less than a second, synchronization across app servers, etc.). Actually using this indexContinue reading “Popping Timestamps into ObjectIds”
SQL to MongoDB: An Updated Mapping
The aggregation pipeline code has finally been merged into the main development branch and is scheduled for release in 2.2. It lets you combine simple operations (like finding the max or min, projecting out fields, taking counts or averages) into a pipeline of operations, making a lot of things that were only possible by usingContinue reading “SQL to MongoDB: An Updated Mapping”
On working at 10gen
10gen is trying to hire a gazillion people, so I’m averaging two interviews a day (bleh). A lot of people have asked what it’s like to work on MongoDB, so I thought I’d write a bit about it. A Usual Day Get in around 10am. Check if there are any commercial support questions that needContinue reading “On working at 10gen”
Getting Started with MMS
Edit: since this was written, Sam has written some excellent documentation on using MMS. I recommend reading through it as you explore MMS. Telling someone “You should set up monitoring” is kind of like telling someone “You should exercise 20 minutes three times a week.” Yes, you know you should, but your chair is soContinue reading “Getting Started with MMS”
PS1++
Since MongoDB was first created, the Mongo shell prompt has just been: > A couple of months ago, my prompt suddenly changed to: myReplSetName:SECONDARY> It’s nice to have more information the prompt, but 1) I don’t care about the replica set name and 2) a programmer’s prompt is very personal. Having it change out fromContinue reading “PS1++”
Mongo in Flatland
MongoDB’s geospatial indexing lets you use a collection as a map. It works differently than “normal” indexing, but there’s actually a nice, visual way to see what geospatial indexing does. Let’s say we have a 16×16 map; something that looks like this: All of the coordinates in our map (as described above) are somewhere betweenContinue reading “Mongo in Flatland”