Storing names vs retrieving from cache by id
Simple mo开发者_StackOverflow中文版ngodb collection which stores sent emails:
{
msgid: objectid
senderid: <some objectid>,
sendername: <some name>,
recip: [{memid:<objectid>, name:<some name>}, {memid:<objectid>, name:<some name>}, ...]
}
contains information about message sender and recipients. Now, I'm trying to decide whether I should store sender/recipients names in the message or resolve them after I retrieve messages. By "resolve" I mean look for names by id in memcached cache of the main system. There might be 1-10 recipients per message, and I retrieve 10-20 messages per request, so in teh worst case scenarion I would need to lookup 200 names per page request. The site will be high load, so I'm concerned about the load on memcached, but on the other side storing names along with teh messages will increase disk space used dramatically.
Any suggestion is highly appreciated!
storing names along with teh messages will increase disk space used dramatically.
Don't care about disk space -- disk space is nothing, it is cheap.
If your system will highload store at recip
everything you need (even mother, father names ;)), no doubt.
- Denormalize your data in order to increase application speed and decrease number of request to database(even to memcache).
- Update denormalized data in background if need.
I doing in way described above in my projects and everything working fast ;). But it's only my opinion and my solution. Other peoples may think different.
精彩评论