Explicit disable MySQL query cache in some parts of program
In a Django project, some cronjob 开发者_开发百科programs are mainly used for administrative or analysis purposes, e.g. generating site usage stats, rotating user activities log, etc.
We probably do not hope MySQL to cache queries in those programs to save memory usage and improve query cache efficiency.
Is it possible to turn off MySQL query cache explicitly in those programs while keep it enabled for other parts including all views.py
?
Per http://dev.mysql.com/doc/refman/5.1/en/query-cache-configuration.html
Individual clients can control cache behavior for their own connection by setting the SESSION query_cache_type value. For example, a client can disable use of the query cache for its own queries like this:
mysql> SET SESSION query_cache_type = OFF;
There's not usually a compelling reason to bother, though. The query cache isn't nearly as important as you might think, particularly during off-peak periods (which I assume is when you would run the cron jobs).
精彩评论