湘潭网站建设 就找磐石网络,人和动物做的电影网站,侧边栏jquery网站后台,小程序免费制作平台360转自#xff1a;http://www.169it.com/article/5994930453423417575.html为了测试sql语句的效率#xff0c;有时候要不用缓存来查询。使用SELECT SQL_NO_CACHE ...语法即可SQL_NO_CACHE的真正作用是禁止缓存查询结果#xff0c;但并不意味着cache不作为结果返回给query。目前…转自http://www.169it.com/article/5994930453423417575.html为了测试sql语句的效率有时候要不用缓存来查询。使用SELECT SQL_NO_CACHE ...语法即可SQL_NO_CACHE的真正作用是禁止缓存查询结果但并不意味着cache不作为结果返回给query。目前流传的SQL_NO_CACHE不外乎两种解释1.对当前query不使用数据库已有缓存来查询则当前query花费时间会多点2.对当前query的产生的结果集不缓存至系统query cache里则下次相同query花费时间会多点我做了下实验似乎两种都对。sql_cache意思是说查询的时候使用缓存。对SQL_NO_CACHE的解释及测试如下:SQL_NO_CACHE means that the query result is not cached. It does not mean that the cache is not used to answer the query.You may use 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 users 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)MyBatis的对CACHE的应用MyBatis的flushCache和useCache的使用(1)当为select语句时flushCache默认为false表示任何时候语句被调用都不会去清空本地缓存和二级缓存。useCache默认为true表示会将本条语句的结果进行二级缓存。(2)当为insert、update、delete语句时flushCache默认为true表示任何时候语句被调用都会导致本地缓存和二级缓存被清空。useCache属性在该情况下没有。当为select语句的时候如果没有去配置flushCache、useCache那么默认是启用缓存的所以如果有必要那么就需要人工修改配置修改结果类似下面……update 的时候如果 flushCachefalse则当你更新后查询的数据数据还是老的数据。