Home » Linux » Prevent a MySQL query from using the query cache

Prevent a MySQL query from using the query cache


Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2146

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2146

Whilst I was busy trying to optimize a MySQL query I got annoyed by the fact that when you make use of MySQL’s query cache that a query gets cached. When that happens a second time you execute the query it’s being looked up and the cached results are being returned. If you want to optimize a query and test its performance this can be quite annoying.

Luckily I found out there’s an easy solution to this problem. Just make use of SQL_NO_CACHE┬álike this:

  1.  

Now when you run this query it makes sure MySQL doesn’t store it in its query cache.

Posted in Linux, Mac, News, Windows and tagged as

Comments are closed.