mysql查看数据库状态

很赞的文章:https://codeplayer.vip/p/j7sc4
官方教程是最应该查看的文档:https://dev.mysql.com/doc/refman/5.5/en/show.html

我真正关心的数据

  • 比如一秒钟到底能插入多少行数据?
  • 慢查询有多少?
    慢是一个相对概念,慢的绝对值时间是可以设置的,例如我设置long_query_time为10秒,那么但凡超过10秒的查询都可以认为是慢查询
  • 查询操作的超时时间

mysql中系统变量什么意思?怎么查看系统变量?
https://blog.csdn.net/leshami/article/details/39585253

show variables

系统变量实际上用于控制数据库的一些行为和方式的参数。比如我们启动数据库的时候设定多大的内存,使用什么样的隔离级别,日志文件的大小,存放位置等等一系列的东东。

show processlist

在这里插入图片描述

show status

SHOW [统计范围] STATUS [LIKE ‘状态项名称’]
–统计范围关键字分为GLOBAL和SESSION(或LOCAL)两种。

show status命令,但是看得眼花缭乱,此时可以加上like筛选
在这里插入图片描述

mysql 里面常用变量说明

com_xxx
The Com_xxx statement counter variables indicate the number of times each xxx statement has been executed
例如 com_select表示select语句执行次数

--查看MySQL本次启动后的运行时间(单位:秒)
show status like 'uptime';
 

--查看select语句的执行数
show [global] status like 'com_select';
 

--查看insert语句的执行数
show [global] status like 'com_insert';
 

--查看update语句的执行数
show [global] status like 'com_update';
 

--查看delete语句的执行数
show [global] status like 'com_delete';
 

--查看试图连接到MySQL(不管是否连接成功)的连接数
show status like 'connections';
 

--查看线程缓存内的线程的数量。
show status like 'threads_cached';
 

--查看当前打开的连接的数量。
show status like 'threads_connected';
 

--查看当前打开的连接的数量。
show status like 'threads_connected';
 

--查看创建用来处理连接的线程数。如果Threads_created较大,你可能要增加thread_cache_size值。
show status like 'threads_created';
 

--查看激活的(非睡眠状态)线程数。
show status like 'threads_running';
 

--查看立即获得的表的锁的次数。
show status like 'table_locks_immediate';
 

--查看不能立即获得的表的锁的次数。如果该值较高,并且有性能问题,你应首先优化查询,然后拆分表或使用复制。
show status like 'table_locks_waited';
 

--查看创建时间超过slow_launch_time秒的线程数。
show status like 'slow_launch_threads';
 

--查看查询时间超过long_query_time秒的查询的个数。
show status like 'slow_queries';

鱼和熊掌不可兼得的例子
可靠性和大并发之间。超时时间短,接受的连接会多一点,可是没有办法保证请求总是正确响应,超时时间长,占用连接不能释放,导致连接池慢了,不能为新用户提供服务。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值