I want to record activity log of all the users in our service, using MongoDB.
Currently, we have a structure as follows:
{
'_id' : 'user_id',
'activites' : [
{time : blah blah, action : blah blah, ...},
{time : blah blah, action : blah blah, ...},
{time : blah blah, action : blah blah, ...},
]
}
but we found out that growth of embedded documents results in the slowdown of update performance.
now we're considering a change in the data schema, which is migrating embedded document to a separate collection, and using the reference model.
if we change the structure, however, there are still problems.
(1) # of references still grows. can we avoid performance issue? (2) if we stop using reference, select performance will degrade.
any good ideas?