Aleksei T
unread,Feb 19, 2011, 6:58:27 PM2/19/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongod...@googlegroups.com
This group is so helpful I can't stop asking things :))
We are considering a design where we would store a document with an element representing a flexible unique combination of several values, in the spirit of the GROUP BY clause in SQL, and a flexible number of counters for it.
We are choosing between the better approach for performance and the way it would be queried:
Approach 1 - flatten out the structure and have a large number of really small documents representing all the unique combinations for a particular time period (e.g. day), example:
{ id:1, time:1298159028, groups:["x","y","z"], aggregates: { bytes:3245, requests:345 } }
{ id:1, time:1298159028, groups:["a","b","c"], aggregtaes: { bytes:4532, requests:124} }
...more documents like that...
Approach 2 - combine all the unique combinations as sub-elements in a single document for the time period, example:
{ id:1, time:1298159028,
data: {
"['x','y','z']" : { bytes:3245, requests:345 }
"['a','b','c']" : { bytes:4532, requests:124}
...more elements like that...
{
So, basically it's a choice between the a larger number of smaller-size docs (flattened out) vs a smaller number of larger docs per similar time period.
On the query side, it will likely be queried by the id and a range of datetime period, not individual unique group items.
So, my initial gut feeling is that it's better to go with #2 as query would return a single document per time period. The downside is the arbitrary size of the resulting document and a concern that it might hit the upper document size limit (16MB), but it is probably not a huge concern.
Would be interesting to hear pros and cons as I am sure a lot of people have made trade-off decisions like that and could share some of the experience :)
Thanks everyone, this group is great :)