Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL best practices to use SQL_CACHE and SQL_NO_CACHE

Tags:

mysql

caching

MySQL allows us to create select statements with usage of SQL_CACHE and SQL_NO_CACHE options. These options affect caching of query results in the query cache. But for which queries is it better to use SQL_CACHE option and for which SQL_NO_CACHE one? Or maybe it is better doesn't use it at all?

like image 624
Eugene Manuilov Avatar asked Dec 25 '11 23:12

Eugene Manuilov


1 Answers

Generally, you shouldn't have to use this at all. SQL_CACHE is only necessary if queries are not cached by default, which they are in the default configuration. SQL_NO_CACHE is useful if you know a particular query will not be used again in the near future, especially if the result set is large. The goal is to avoid cluttering the cache with results which won't be needed again.

like image 133
Michael Mior Avatar answered Nov 15 '22 22:11

Michael Mior