mysql缓存参数
对mysql的优化不在行,搞过几次优化,但是都不是很理想,还是浪费资源太多。一直发现我的mysql的缓存命中率极差,情况良好的时候到达过60-70%,但是运行时间一长,只有10-20%。查了一些资料,关于缓存的一些参数记录
mysql> SHOW VARIABLES LIKE ‘%query_cache%’;
+——————————+———-+
| Variable_name | Value |
+——————————+———-+
| have_query_cache | YES |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 67108864 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
+——————————+———-+
6 rows in set (0.00 sec)
have_query_cache
是否支持查询缓存区 “YES”表是支持查询缓存区
query_cache_limit
可缓存的Select查询结果的最大值 1048576 byte /1024 = 1024kB 即最大可缓存的select查询结果必须小于1024KB
query_cache_min_res_unit
每次给query cache结果分配内存的大小 默认是 4096 byte 也即 4kB
经过我测试,
set GLOBAL query_cache_min_res_unit=4096; 的时候,碎片会比较多,在3000多。
set GLOBAL query_cache_min_res_unit=2046;的时候,碎片比较少,在1000多。
但是过小会增加IO负担
mysql>show status;
中间有一段 Qcache_开头的
Qcache_free_blocks | 4984 &
相关文档:
1、选取最适用的字段属性
MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快。因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小。例如,在定义邮政编码这个字段时,如果将其设置为CHAR(255),显然给数据库增加了不必要的空间,甚至使 ......
To familiarize you with the basics, we will describe the simplest
possible configuration for a functional MySQL Cluster. After this,
you should be able to design your desired setup from the
information provided in the other relevant sections of this
chapter.
......
Administration 管理
Kill a Thread 结束一个线程
mysql > KILL 999;
Optimize Table 优化表
mysql > OPTIMEZE TABLE foo;
Reload Users Permissions 刷新MySQL系统权限相关表
mysql > FLUSH PRIVILEGES;
Repair Table 修复表
mysql > ......
//得分计算四舍五入
SELECT ROUND((SUM(getfeng)/SUM(totalfeng))*100) as feng from answerdata WHERE uid='151' AND targetid IS NOT NULL
1.ceil () /ceiling() 向上取整
例: ceil(1.2) = 2
2.floor () 向下取整
例: floor(1.2) = 1
3.round() 四舍五入
&n ......