mySql性能优化

 

 

查看数据库的最大连接数

show VARIABLES like '%max_connections%'
set GLOBAL max_connections = 200
max_connections=151

查看是否开启缓存

show variables like '%query_cache_type%'
SET GLOBAL query_cache_size = 4000;
SET GLOBAL query_cache_size = 134217728;

 

注:MYISIM也叫非聚集索引

 

show VARIABLES like 'innodb_file_per_table'
set global innodb_file_per_table=off

 

 

 

1. lock table testmysam READ 启动另外一个session select * from
testmysam 可以查询
2. insert into testmysam value(2);
update testmysam set id=2 where id=1;
报错
3.在另外一个session中
insert into testmysam value(2); 等待
4.在同一个session中
insert into testdemo value(2,'2','3'); 报错
select * from testdemo ; 报错
5.在另外一个session中
insert into testdemo value(2,'2','3'); 成功
6.加索在同一个session 中 select s.* from testmysam s 报错
lock table 表名 as 别名 read;
查看 show status LIKE 'table_locks_waited' 表被锁过几次

注:myisim索引的共享读锁说白了 就是锁住了当前表,所有的读操作是可以的,但是更新插入操作是需要等待锁释放后才能操作

        独占写锁则表示 其他的会话要操作当前表 ,必须要等到锁释放后才能操作,包括查询和更新

 

也可以用工具来修改

注:关于锁的理解可以在参考:  https://blog.csdn.net/localhost01/article/details/78720727

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值