source

느린 쿼리 로그(MariaDB)에 시간이 많이 걸린다

bestscript 2022. 11. 2. 22:45

느린 쿼리 로그(MariaDB)에 시간이 많이 걸린다

느린 쿼리 로그 분석기를 실행하면 요청 시간이 몇 초 만에 표시됩니다.이러한 요구를 수동으로 실행하려고 하면 매우 빠르게 실행됩니다(0.01초).뭐가 문제죠?

mysql Ver 15.1 Readline 5.1을 사용한 Linux(x86_64)용 Distributed 10.1.9-MariaDB

CREATE DEFINER = 'root'@'192.168.1.101' EVENT `DEL_EXPIRED_BANS`
  ON SCHEDULE EVERY 10 MINUTE STARTS '2013-10-18 13:38:54'
  ON COMPLETION NOT PRESERVE
  ENABLE
  COMMENT ''  DO
BEGIN
update users set ban_type=0, ban_expire=null, ban_expire=null, ban_reason=null 
 where ban_type > 0 and ban_expire < CURRENT_TIMESTAMP();
 delete from `flash_client_log` where TIMESTAMPADD(DAY,4, `dttm` ) < CURRENT_TIMESTAMP() and `log_type`=1;
  delete from `flash_client_log` where TIMESTAMPADD(DAY,4, `dttm` ) < CURRENT_TIMESTAMP() and `log_type`=0;
END;

[root@xy1 GameServer]# mysqldumpslow - a - s t - t 15 / var / log / mysql _ slow . log

Reading mysql slow query log from /var/log/mysql_slow.log
Count: 1344  Time=18446679593472.00s (24792337373626364s)  Lock=0.00s (0s)  Rows_sent=0.0 (0), Rows_examined=41408.5 (55653024), Rows_affected=0.0 (0), 2users@localhost
  update users set ban_type=0, ban_expire=null, ban_expire=null, ban_reason=null
  where ban_type > 0 and ban_expire < CURRENT_TIMESTAMP()

Count: 672  Time=18446679593471.92s (12396168686813130s)  Lock=0.15s (98s)  Rows_sent=0.0 (0), Rows_examined=33953.0 (22816416), Rows_affected=0.0 (0), root[root]@localhost
  delete from `flash_client_log` where TIMESTAMPADD(DAY,1, `dttm` ) < CURRENT_TIMESTAMP() and `log_type`=1

Count: 672  Time=18446679593471.92s (12396168686813128s)  Lock=0.15s (100s)  Rows_sent=0.0 (0), Rows_examined=33953.0 (22816416), Rows_affected=0.0 (0), root[root]@localhost
  delete from `flash_client_log` where TIMESTAMPADD(DAY,3, `dttm` ) < CURRENT_TIMESTAMP() and `log_type`=0

Count: 672  Time=18446679593471.91s (12396168686813120s)  Lock=0.09s (63s)  Rows_sent=0.0 (0), Rows_examined=14599.2 (9810684), Rows_affected=22.5 (15144), root[root]@192.168.1.101
  delete from `flash_client_log` where TIMESTAMPADD(DAY,4, `dttm` ) < CURRENT_TIMESTAMP() and `log_type`=1

Count: 672  Time=18446679593470.33s (12396168686812064s)  Lock=1.70s (1140s)  Rows_sent=0.0 (0), Rows_examined=28865.1 (19397320), Rows_affected=0.4 (237), root[root]@192.168.1.101
  delete from `flash_client_log` where TIMESTAMPADD(DAY,4, `dttm` ) < CURRENT_TIMESTAMP() and `log_type`=0

Count: 1  Time=18446679639052.95s (18446679639052s)  Lock=0.00s (0s)  Rows_sent=0.0 (0), Rows_examined=0.0 (0), Rows_affected=0.0 (0), billiards3d_net[billiards3d_net]@localhost
  delete from guests_log WHERE dttm < DATE_SUB(CURDATE(), INTERVAL 1 WEEK)

앞서 댓글에서 언급했듯이 이 질문을 바탕으로 버그 보고서가 작성되었습니다.이 버그는 수정되었습니다.이 수정은 5.5 트리로 제공되며 MariaDB의 다음 릴리스인 5.5.54, 10.0.29, 10.1.21, 10.2.3과 함께 출시됩니다.

시계가 거꾸로 간다.당신은 침착해야 합니다. 빛의 속도를 넘지 마세요!

정말...지난 15년 동안 MySQL의 모든 버전에서 주기적으로 봐왔습니다.지금 보고 계신 번호는 아마-1의 취급을 받다UNSIGNED번호.

권장사항: 0으로 간주하고 다음으로 넘어갑니다.

이 경우 요약(mysqldumpslow)이 있기 때문에 이 작업은 어렵습니다.문제의 원인은 저속 로그 어딘가에 있습니다.내일(slowlog의 다른 부분에서) 다시 발생할 경우 http://bugs.mysql.com에 버그를 제출합니다(아직 여러 개가 없습니다).

언급URL : https://stackoverflow.com/questions/41099516/huge-time-in-slow-query-log-mariadb