慢查询日志分析
Posted igoodful
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了慢查询日志分析相关的知识,希望对你有一定的参考价值。
# Time: 2020-03-13T21:02:40.710834+08:00 # User@Host: ashes2_x[ashes2_x] @ [10.10.10.10] Id: 93181 # Schema: Last_errno: 0 Killed: 0 # Query_time: 4.698308 Lock_time: 0.000288 Rows_sent: 10000 Rows_examined: 900000 Rows_affected: 0 # Bytes_sent: 894213 Tmp_tables: 1 Tmp_disk_tables: 1 Tmp_table_sizes: 16384 # InnoDB_trx_id: 0 # QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: Yes # Filesort: No Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 0 InnoDB_IO_r_bytes: 0 InnoDB_IO_r_wait: 0.000000 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 8102 SET timestamp=1584104560; SELECT * FROM (select id,title,keywords,category_id,create_time from tv_ashes.short_movie where publish_status=10 limit 880000,10000) t; # Time: 2020-03-13T21:02:40.724336+08:00 # User@Host: ashes2_x[ashes2_x] @ [10.10.10.11] Id: 93185 # Schema: Last_errno: 0 Killed: 0 # Query_time: 4.711351 Lock_time: 0.000204 Rows_sent: 10000 Rows_examined: 910000 Rows_affected: 0 # Bytes_sent: 920165 Tmp_tables: 1 Tmp_disk_tables: 1 Tmp_table_sizes: 16384 # InnoDB_trx_id: 0 # QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: Yes # Filesort: No Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 175 InnoDB_IO_r_bytes: 2867200 InnoDB_IO_r_wait: 0.025178 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 8107 SET timestamp=1584104560; SELECT * FROM (select id,title,keywords,category_id,create_time from tv_ashes.short_movie where publish_status=10 limit 890000,10000) t; # Time: 2020-03-13T21:02:41.572673+08:00 # User@Host: ashes2_x[ashes2_x] @ [10.10.10.10] Id: 93163 # Schema: Last_errno: 0 Killed: 0 # Query_time: 3.642372 Lock_time: 0.000196 Rows_sent: 10000 Rows_examined: 920000 Rows_affected: 0 # Bytes_sent: 897788 Tmp_tables: 1 Tmp_disk_tables: 1 Tmp_table_sizes: 16384 # InnoDB_trx_id: 0 # QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: Yes # Filesort: No Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 5 InnoDB_IO_r_bytes: 81920 InnoDB_IO_r_wait: 0.001347 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 8107 SET timestamp=1584104561; SELECT * FROM (select id,title,keywords,category_id,create_time from tv_ashes.short_movie where publish_status=10 limit 900000,10000) t;
##########################################################################################################################################
# Time: 2020-03-13T21:02:41.572673+08:00 # User@Host: ashes2_x[ashes2_x] @ [10.10.10.10] Id: 93163 # Schema: Last_errno: 0 Killed: 0 # Query_time: 3.642372 Lock_time: 0.000196 Rows_sent: 10000 Rows_examined: 920000 Rows_affected: 0 # Bytes_sent: 897788 Tmp_tables: 1 Tmp_disk_tables: 1 Tmp_table_sizes: 16384 # InnoDB_trx_id: 0 # QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: Yes # Filesort: No Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 5 InnoDB_IO_r_bytes: 81920 InnoDB_IO_r_wait: 0.001347 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 8107 SET timestamp=1584104561; SELECT * FROM (select id,title,keywords,category_id,create_time from tv_ashes.short_movie where publish_status=10 limit 900000,10000) t;
###########################################################################################################################################
一般而言,慢查询日志都是这样固定的组成:
一共13行:
第1行:时间
第2行:用户信息
第3行:模式信息
第4行:时间和行数
第5行:数据量,表信息
第6行:事务id
第7行:
第8行:文件排序
第9行:
第10行:
第11行:
第12行:时间戳
第13行:慢查询语句
# Time: 2020-03-09T23:01:26.116987+08:00 # User@Host: skip-grants user[igoodful] @ [127.0.0.1] Id: 3 # Schema: tv_error Last_errno: 1880 Killed: 0 # Query_time: 15.720529 Lock_time: 0.001370 Rows_sent: 0 Rows_examined: 0 Rows_affected: 393806 # Bytes_sent: 58 Tmp_tables: 0 Tmp_disk_tables: 0 Tmp_table_sizes: 0 # InnoDB_trx_id: 0 # QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No # Filesort: No Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 228 InnoDB_IO_r_bytes: 3735552 InnoDB_IO_r_wait: 0.040748 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 6515 use tv_igoodful; SET timestamp=1583766086; ALTER TABLE `mydb`.`video_old` FORCE; # Time: 2020-03-09T23:01:27.371086+08:00 # User@Host: skip-grants user[igoodful] @ [127.0.0.1] Id: 3 # Schema: tv_error Last_errno: 1880 Killed: 0 # Query_time: 1.253988 Lock_time: 0.001060 Rows_sent: 0 Rows_examined: 0 Rows_affected: 32369 # Bytes_sent: 56 Tmp_tables: 0 Tmp_disk_tables: 0 Tmp_table_sizes: 0 # InnoDB_trx_id: 0 # QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No # Filesort: No Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 217 InnoDB_IO_r_bytes: 3555328 InnoDB_IO_r_wait: 0.020998 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 1024 SET timestamp=1583766087; ALTER TABLE `mydb`.`video_old` FORCE;
以上是关于慢查询日志分析的主要内容,如果未能解决你的问题,请参考以下文章