What has been started more than five weeks back as my “small” personal MongoDB experiment is now entering its fifth round. Still I am following the corresponding MongoDB course at 10gen and this week it is all about aggregation functions. You know this is when in relational databases “group by”-clauses show up and things get a little bit more complicated than the usual Selects and Updates. As it is already some kind of tradition now for this series another film title has been chosen to be the godfather for this (fifth) posting. Having worked for several years in a project implementing a Network Data Warehouse on top of Oracle I had my share in (relational) aggregation functions. Thus I am really curious how this will be done in MongoDB. Let’s start.
“$sort does pretty much what you’d expect. It sorts the documents. But there are few things to keep in mind when you use $sort and the first is that $sort can be a real memory hug.” -Quotes from the course
Aggregation Functions – Warmup
In this paragraph we are taking a first look at the syntax and general concepts used for the aggregation functions in MongoDB. For this we will execute what would be a “count(*)” SQL-query in a relational database. As a sample collection we are re-using one of the already used collections from an earlier example:
(read more…)