时间:2021-07-01 10:21:17 帮助过:26人阅读
mysql> show variables like ‘slow_query%‘; +---------------------+----------------------------------------------+ | Variable_name | Value | +---------------------+----------------------------------------------+ | slow_query_log | ON | | slow_query_log_file | /rdsdbdata/log/slowquery/mysql-slowquery.log | +---------------------+----------------------------------------------+ 2 rows in set mysql> show variables like ‘slow_launch_time‘; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | slow_launch_time | 1 | +------------------+-------+ 1 row in set
看到慢日志已经开启 登录aws cloudwatch查看慢日志发现大部分为这条sql
# User@Host: admin[admin] @ [10.0.11.12] Id: 2302 # Query_time: 3.602910 Lock_time: 0.100585 Rows_sent: 2 Rows_examined: 4454 SET timestamp=1594629311; SELECT a.enum_value,a.bsh_enum_value FROM external_mapping a LEFT JOIN external_bsh_command_key b ON a.bsh_command_id=b.id LEFT JOIN external_bsh_command_options c ON a.bsh_options_id=c.id LEFT JOIN external_command_key d ON a.command_id=d.id LEFT JOIN category h ON a.category_id=h.id where 1=1 AND b.code=‘BSH.Common.Status.Event‘ AND c.code=‘BSH.Common.Setting.Rm4Valve‘ AND d.code=‘Rm4_Valve‘ AND a.platform_id=119 AND h.cname = ‘TT‘;
mysql> show OPEN TABLES where In_use > 0; #查看是否有锁表 SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; #查看正在锁的事务 Empty set SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; #查看等待锁的事务 Empty set 暂时没有看到锁表的情况
mysql> show global status like ‘Qca%‘; +-------------------------+-----------+ | Variable_name | Value | +-------------------------+-----------+ | Qcache_free_blocks | 1 | | Qcache_free_memory | 134199912 | | Qcache_hits | 0 | | Qcache_inserts | 0 | | Qcache_lowmem_prunes | 0 | | Qcache_not_cached | 44950579 | | Qcache_queries_in_cache | 0 | | Qcache_total_blocks | 1 | +-------------------------+-----------+ 8 rows in set 说明: Qcache_hits:查询缓存命中次数。 Qcache_inserts:将查询和结果集写入到查询缓存中的次数。 Qcache_not_cached:不可以缓存的查询次数。 Qcache_queries_in_cache:查询缓存中缓存的查询量。
查看到缓存命中为0%
mysql> show engine innodb status;
数据库CPU 100%处理记录
标签:扫描 优化 同事 admin asc 变量 tab source bsp