mysql diagnose problems

Step 1. Run Use Case (Sample Query)

select * from output_trade_log;

Step 2. Analyze the Root Casue (Show current user and connection)

select CURRENT_USER(), CONNECTION_ID();

Step 3. Rule Out Benign Issues (Show all the processes)
SHOW FULL PROCESSLIST;

Step 4. Isolate Malign Issues

     4.1 show all thread_id of current connection

      select THREAD_ID, PROCESSLIST _ID from performance_schema.threads where processlist_id = connection_id();

     4.2 Select all the waits for current events

      select * from performance_scheam.events_waits_current;

      4.3 Select only the event waits for current threads

      select event_name,(timer_end-timer_start)/1000000000 as 'Duration (ms)', object_name,object_type,index_name, operation from  performance_schema.event_waits_current e inner join performance_schema.threads t on e.thread_id = t.thread_id where processlist_id = connection_id();

Step 5. Take Appropriate Correcive Actions (turn off the logging)

  set global general_log = 'OFF';

6. repeat the process (go to step 1)

e.g.

select a.DIGEST_TEXT as query, a.COUNT_STAR as exec_count, sec_to_time(a.SUM_TIMER_WAIT/1000000000000) as exec_time_total, sec_to_time(a.MAX_TIMER_WAIT/1000000000000) as exec_time_max, (a.AVG_TIMER_WAIT/1000000000) as exec_time_avg_ms, a.SUM_ROWS_SENT as rows_sent, a.SUM_ROWS_EXAMINED as rows_scanned from performance_schema.events_statements_summary_by_digest a order by a.SUM_TIMER_WAIT desc;

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值