We are planning on using MongoDB to store large amounts of analytics data such as views and clicks. I'm unsure on the best way to structure the documents within MongoDB to aid querying and reduce database size.
We need to record actions agains a pagename, client and the type of action. Ideally we need stats which go down the the year/month/day/hour level, we don't need or care about views per second or minute. While this document structure looks ok, I'm aware 100 vistors would generate a 100 new documents.
{
"_id" : ObjectId( "4dabdef81a34961506040000" ),
"pagename" : "Hello",
"action" : "view",
"client" : "client-name",
"time" : Date( "Mon Apr 18 07:49:28 2011" )
}
Is there best practice way of doing this, either using $inc or Capped Collections?