show processlist
MariaDB [employees]> show processlist;
+----+------+--------------------+-----------+---------+------+-------+------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+----+------+--------------------+-----------+---------+------+-------+------------------+----------+
| 13 | root | 192.168.56.1:49182 | employees | Sleep | 0 | | NULL | 0.000 |
| 14 | root | localhost | employees | Query | 0 | init | show processlist | 0.000 |
+----+------+--------------------+-----------+---------+------+-------+------------------+----------+
2 rows in set (0.00 sec)
MariaDB [employees]> show processlist;
+----+------+--------------------+-----------+---------+------+--------------+----------------------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+----+------+--------------------+-----------+---------+------+--------------+----------------------------------+----------+
| 13 | root | 192.168.56.1:49182 | employees | Query | 3 | Sending data | select * from employees,salaries | 0.000 |
| 14 | root | localhost | employees | Query | 0 | init | show processlist | 0.000 |
+----+------+--------------------+-----------+---------+------+--------------+----------------------------------+----------+
2 rows in set (0.00 sec)
MariaDB [employees]> show explain for 13;
+------+-------------+-----------+------+---------------+------+---------+------+---------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-----------+------+---------------+------+---------+------+---------+-------+
| 1 | SIMPLE | employees | ALL | NULL | NULL | NULL | NULL | 299113 | |
| 1 | SIMPLE | salaries | ALL | NULL | NULL | NULL | NULL | 2837904 | |
+------+-------------+-----------+------+---------------+------+---------+------+---------+-------+
2 rows in set, 1 warning (0.03 sec)
MariaDB [employees]> show explain for 13;
ERROR 1933 (HY000): Target is not running an EXPLAINable command
log_slow_verbosity 시스템 변수 옵션 |
microtime : 각종정보를 마이크로 초 단위 표시 |
query_plan : SELECT 쿼리 실행계획 간략화 표시 |
full : 모든 옵션을 표시함 |
explain : 10.0.5 부터 추가된 옵션 , explain 결과 모두 기록하게 함 |
MariaDB [employees]> explain format=JSON
-> select count(*) from employees e,dept_emp de where de.emp_no=e.emp_no and e.last_name like '%M%';
----------------------------------------------------------------------+
| EXPLAIN |
----------------------------------------------------------------------+
| {
"query_block": {
"select_id": 1,
"table": {
"table_name": "e",
"access_type": "ALL",
"possible_keys": ["PRIMARY"],
"rows": 299113,
"filtered": 100,
"attached_condition": "(e.last_name like '%M%')"
},
"table": {
"table_name": "de",
"access_type": "ref",
"possible_keys": ["PRIMARY", "emp_no"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["emp_no"],
"ref": ["employees.e.emp_no"],
"rows": 1,
"filtered": 100,
"using_index": true
}
}
} |
----------------------------------------------------------------------+
MariaDB [(none)]> show status like '%Memory%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| Innodb_read_views_memory | 192 |
| Memory_used | 67464 |
| Qcache_free_memory | 33429488 |
+--------------------------+----------+
3 rows in set (0.00 sec)
MariaDB [(none)]> show global status like '%Memory%';
+--------------------------+-----------+
| Variable_name | Value |
+--------------------------+-----------+
| Innodb_read_views_memory | 192 |
| Memory_used | 207512784 |
| Qcache_free_memory | 33429488 |
+--------------------------+-----------+
3 rows in set (0.01 sec)
MariaDB [(none)]> use information_schema
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [information_schema]> select id,user,host,memory_used from processlist;
+----+------+--------------------+-------------+
| id | user | host | memory_used |
+----+------+--------------------+-------------+
| 16 | root | localhost | 84584 |
| 15 | root | 192.168.56.1:49183 | 67464 |
+----+------+--------------------+-------------+
2 rows in set (0.00 sec)
MariaDB [information_schema]> select sum(memory_used) from processlist;
+------------------+
| sum(memory_used) |
+------------------+
| 152048 |
+------------------+
1 row in set (0.00 sec)
MariaDB [information_schema]> show processlist;
+----+------+--------------------+--------------------+---------+------+-------+------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+----+------+--------------------+--------------------+---------+------+-------+------------------+----------+
| 15 | root | 192.168.56.1:49183 | employees | Sleep | 2199 | | NULL | 0.000 |
| 16 | root | localhost | information_schema | Query | 0 | init | show processlist | 0.000 |
+----+------+--------------------+--------------------+---------+------+-------+------------------+----------+
2 rows in set (0.00 sec)
MariaDB [information_schema]> kill connection 15;
Query OK, 0 rows affected (0.03 sec)
MariaDB [information_schema]> show processlist;
+----+------+-----------+--------------------+---------+------+-------+------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+----+------+-----------+--------------------+---------+------+-------+------------------+----------+
| 16 | root | localhost | information_schema | Query | 0 | init | show processlist | 0.000 |
+----+------+-----------+--------------------+---------+------+-------+------------------+----------+
1 row in set (0.00 sec)
특정 커넥션의 쿼리 강제 종료 : KILL QUERY 스레드 아이디 |
특정 커넥션의 쿼리를 쿼리 아이디로 강제 종료 : KILL QUERY ID 쿼리ID값 |
SELECT * FROM PROCESSLIST; 컬럼 QUERY_ID 조회 후 KILL QUERY ID 수행 |
(KIIL QUERY 와 KILL QUERY ID 차이 : 전자 모든 실행중인 쿼리 종료,후자 특정 쿼리만 종료) |
특정 유저의 커넥션이나 쿼리 강제 종료 : KILL CONNECTION USER '유저명' OR '유저명@%'; |
KILL QUERY USER '유저명' OR '유저명@%'; |
강제종료의 수준 조절 : KILL HARD |
SOFT QUERY 쿼리ID ; |
- 강좌 URL : http://www.gurubee.net/lecture/4210
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.