开发者

Necessity of static cache for mysql queries?

This seems to be a clear issue; but I was unable to find an explicit answer. Consider a simple mysql database with indexed ID; without any complicated process. Just reading a row with WHERE clause. Does it really need to be cached? Reducing mysql queries apparently satisfies every one. But I tested reading a text from a flat cache file and by mysql query in a for loop of 1 - 100,000 cycles. R开发者_运维技巧eading from flat file was only 1-2 times faster (but needed double memory). The CPU usage (by rough estimate from top in SSH) was almost the same.

Now I do not see any reason for using flat file cache. Am I right? or the case is different in long term? What may make slow query in such a simple system? Is it still useful to reduce mysql queries?

P.S. I do not discuss internal QC or systems like memcached.


It is depending of how you see the problem.

  • There is a limit on number of mysql connection can be established at any one time.
    Holding the mysql connection resources in a busy site could lead to max connection error.

  • Establish a connection to mysql via TCP is a resource eater (if your database is sitting in different server). In this case, access a local disk file will be much faster.

  • If your server is located outside the network, the cost of physical distance will be heavier.

  • If records are updated once daily, stored into cache is truly request once and reused for the day.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜