mysql 操作

1 关联查询更新

UPDATE b 
LEFT JOIN a ON a.id = b.id
SET b.xxx= a.xxx1;

UPDATE b SET hweivideo = (
    SELECT hweivideo1 FROM a WHERE a.id = b.id
)

order by case when

select  *  from 表 order by (CASE live_status WHEN 0 THEN 2 WHEN 1 THEN 1 WHEN 2 THEN 3 END) LIMIT 3; 

show processlist   显示当前正在执行的MySQL连接

show status like 'Max_used_connections';  显示当前使用连接数

查看响应的连接数:

max_used_connections / max_connections * 100% (理想值≈ 85%)

如果max_used_connections跟max_connections相同 那么就是max_connections设置过低或者超过服务器负载上限了,低于10%则设置过大。

max_used_connections数量就是当前连接数量。

 

mysql> show status like 'Threads%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_cached    | 58    |
| Threads_connected | 57    |   ###这个数值指的是打开的连接数
| Threads_created   | 3676  |
| Threads_running   | 4     |   ###这个数值指的是激活的连接数,这个数值一般远低于connected数值
+-------------------+-------+
 
Threads_connected 跟show processlist结果相同,表示当前连接数。准确的来说,Threads_running是代表当前并发数
 
这是是查询数据库当前设置的最大连接数
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 1000  |
+-----------------+-------+
 
可以在/etc/my.cnf里面设置数据库的最大连接数
[mysqld]
max_connections = 1000

max_user_connections=600

系统支持的最大连接max_connections

用户能最大连接进来的数量max_user_connections

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值