MySQL?????????????????λЧ?????SQL???
???????????? ???????[ 2017/4/25 10:07:43 ] ????????????? MySQL
????MySQL?????????????λ???Ч?????SQL????????????????????????????mysqldumpslow?????MySQL???????????????????????????з???????
????MySQL?????????????λ??Щ???Ч?????SQL ?????--log-slow-queries[=file_name]?????????mysqld ??д???????????????????long_query_time ???SQL????????????????????????????λЧ?????SQL ??
????????????????????????????????????÷?????Ч??????????????????????????????λ???????????show processlist????????MySQL????е???????????????????????????????????SQL ???????????????Щ????????????????
????????????????????£?????????????????λ???Ч????SQL ???
??????????????????????????:
????[mysqld]
????log-slow-queries
??????my.cnf ???????????????????????????mysql???????mysql???????????Ч????????????д??????DATADIR???????????????·???£???????????host_name-slow.log ??
?????????????????????????????????????????????????????????????????????????????????????ú????????
????????????? long_query_time ??? ??
????mysql> show variables like 'long%';
????+-----------------+-------+
????| Variable_name | Value |
????+-----------------+-------+
????| long_query_time | 10 |
????+-----------------+-------+
????1 row in set (0.00 sec)
????????????????????????????5??
????mysql> set long_query_time=5;
????Query OK?? 0 rows affected (0.02 sec)
?????????????????????????
????????????????????????5 ?????????????????????У?
????mysql> select count(*) from order2008;
????+----------+
????| count(*) |
????+----------+
????| 208 |
????+----------+
????1 row in set (0.00 sec)
????????????????????????5 ?????ó??????????????У?
????mysql> select count(*) from t_user;
????+----------+
????| count(*) |
????+----------+
????| 6552961 |
????????????????
????[root@localhost mysql]# more localhost-slow.log
????# Time: 081026 19:46:34
????# User@Host: root[root] @ localhost []
????# Query_time: 11 Lock_time: 0 Rows_sent: 1 Rows_examined: 6552961
????select count(*) from t_user;
??????????????У???????????????5 ???SQL????С??5???????г??????????С?
????????????????м???????????????mysqldumpslow?????MySQL???????????????????????????з????????????ж???????mysql_master-slow.log?????????????????????????????
????[root@mysql_master mysql_data]#mysqldumpslow mysql_master-slow.log
????Reading mysql slow query log from mysql_master-slow.log
????Count: 2 Time=11.00s (22s) Lock=0.00s (0s) Rows=1.0 (2)?? root[root]@mysql_master
????select count(N) from t_user;
???????? SQL ????????£???????????????mysqldumpslow ???????????????????????????????N?????檔?????????????????????????????????Ч?????????λ????SQL ?????
??????????????????????????????????????????SQL???а?????????????????£??????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11