Question

Say I have an entity called User and I want to store statistics about the user, for example how many pages he viewed. My dilemma is should I store the statistics in the user entity as a property called "pageviews" or should I create a new entity called UserStatistics, which will store all the statistics and it will be linked to a single user.

The reason I was thinking maybe it's better to create a new entity for statistics is because I will need to use many transactions in order to update the statistics relating to entities that will be otherwise very small, almost entirely read-only, and need to be accessed (memcached) a lot... Will it create a lot of overhead if I store these statistics in the original entity, or is it not siginificant? If I do a lot of transactions on a single entity, will it slow down reading from it?

Was it helpful?

Solution

You should store frequently updated data in a separate entity. Every time you update an entity you incur writing costs on each indexed property even if these properties do not change.

OTHER TIPS

I always create a separate entity for users caller Profile. Profile stores all other user data.

It won't slow down reading times but it might rack up a little more expense $. You could look into storing the "pageviews" in the session and only write it to the datastore when the session is closing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top