Transferred from: http://www.169it.com/article/5994930453423417575.html
In order to test the efficiency of SQL statements, it is sometimes necessary to query without caching. Use Select Sql_no_cache ... The true function of syntax- sql_no_cache is to disallow caching of query results, but does not imply that the cache is not returned to query as a result. The current spread of Sql_no_cache is only two explanations: 1. The current query spends more than 2 of the time on queries that do not use the database's existing cache. The resulting set of results for the current query is not cached in the system query cache. The next time the same query takes more time, I do the next experiment, it seems that both are right. sql_cache means that the cache is used when querying. The explanations and tests of Sql_no_cache are as follows: Sql_no_cache means that the query result was not cached. It does not mean, the cache is not a used to answer the query. You could use the RESET query, cache to remove all queries from the cache, and then your next query should be slow again. Same effect if you change the table, because this makes all cached queries Invalid. mysql> select COUNT (*) from us ers where email = ' hello '; +----------+| COUNT (*) |+----------+| 0 |+----------+1 row in Set (7.22 sec) mysql> Select COUNT (*) from users where email = ' hello '; +----------+| COUNT (*) |+----------+| 0 |+----------+1 row in Set (0.45 sec) mysql> Select COUNT (*) from users where email = ' hello '; +----------+| COUNT (*) |+----------+| 0 |+----------+1 row in Set (0.45 sec) mysql> Select Sql_no_cache Count (*) from users where email = ' hello '; +----- -----+| COUNT (*) |+----------+| 0 |+----------+1 row in Set (0.43 sec)
The application of ================mybatis to the cache ======================
The use of MyBatis Flushcache and UseCacheTurn from: http://blog.csdn.net/ssssny/article/details/52248960 (1) When the SELECT statement is: Flushcache defaults to False, indicating that any time the statement is called, will not erase the local cache and level two cache. UseCache By default is true, indicating that the result of this statement will be cached at level two. (2) When insert, UPDATE, DELETE statement: Flushcache default is True, indicating that any time the statement is called, will cause the local cache and the level two cache is emptied. The UseCache property is not in this case. When the SELECT statement is not configured to configure Flushcache, UseCache, then the default is to enable caching, so if necessary, then you need to manually modify the configuration, the results are similar to the following: <select id= "Save" Parametertype= "XX" flushcache= "true"usecache= "false">......</select> Update if flushcache= "false", then when you update, the query data data is still old data.
"Go" MySQL sql_no_cache (do not use caching at query time) and Sql_cache usage