• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

为什么不记录慢查询?

mysql 搞代码 4年前 (2022-01-09) 54次浏览 已收录 0个评论

㈠ 背景介绍: ㈡ 定位原因: INSERT INTO t (col1, col2, col3, col4, col5, col6, col7) VALUES (3532082239485507011_130_99, 130_99, 130, 99, 3532082239485507011, 2172353000317425008, 29078) ㈢ 处理思路: select trx_id,trx_state,trx_started,tr

㈠ 背景介绍:
㈡ 定位原因:

INSERT INTO t (col1, col2, col3, col4, col5, col6, col7) VALUES ('3532082239485507011_130_99', '130_99', 130, 99, 3532082239485507011, 2172353000317425008, 29078) 

㈢ 处理思路:

select trx_id,trx_state,trx_s<span>本文来源gaodai#ma#com搞*!代#%^码$网*</span>tarted,trx_requested_lock_id,trx_weight,trx_mysql_thread_id from information_schema.innodb_trx where trx_state='RUNNING';

㈣ 我的疑问:
㈤ 原来如此:
㈥ 模拟场景:

Session_A:mysql> begin;Query OK, 0 rows affected (0.00 sec)mysql> select emp_no,hire_date from employees where emp_no=10170 for update;+--------+------------+| emp_no | hire_date  |+--------+------------+|  10170 | 1986-01-02 |+--------+------------+1 row in set (0.00 sec)Session_B:mysql> select emp_no,hire_date,sleep(3) from employees where emp_no=10170 for update;

过段时间在A做commit,B会执行、并被记录到slow log中:

# Time: 140818 22:37:31# User@Host: root[root] @ localhost []  Id:     1# Query_time: 3.049016  Lock_time: 0.018891 Rows_sent: 1  Rows_examined: 1use employees;SET timestamp=1408372651;select emp_no,hire_date,sleep(3) from employees where emp_no=10170 for update;
Session_A:mysql> begin;Query OK, 0 rows affected (0.00 sec)mysql> select emp_no,hire_date from employees where emp_no=10170 for update;+--------+------------+| emp_no | hire_date  |+--------+------------+|  10170 | 1986-01-02 |+--------+------------+1 row in set (0.00 sec)Session_B:mysql> select emp_no,hire_date from employees where emp_no=10170 for update;

㈦ 我的收获:

我们日常做性能剖析实际上应该包括2个方面:

1)基于执行时间的分析

2)基于等待时间的分析

By water

Good Luck!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:为什么不记录慢查询?

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址