Rails 3: Optimize database call
What is the best way to optimize calls to a MongoDB cloud database?
For example: a user c开发者_如何学运维an have 100 tweets or 100000 tweets that needs to be shown in the page.
What shall I do in order to optimize the fetch of the tweets? Given that the old tweets are the same every time, should I cache and only fetch the new ones?
I'm using Ruby Mongo driver.
Just one question: You want to show 100000 tweets on page?
Mongodb load all collections to memory automatically(if enough ram on the server) and return data very, very fast(like from cache).
So i see two optimizations:
- Create indexes
- Limit tweets count per page (you can do it like facebook do it on news wall).
精彩评论