MySQL

MySQL

現在実行しているqueryを表示するには?

show proceslist を使用します。:

mysql> show processlist;
+----+-----------+-----------+-----------+---------+------+--------+---------------------------------------------------+
| Id | User      | Host      | db        | Command | Time | State  | Info                                              |
+----+-----------+-----------+-----------+---------+------+--------+---------------------------------------------------+
| 12 | USERNAME  | localhost | DBNAME    | Query   |    0 | update | INSERT INTO `TABLENAME` (`COLUMN_1`, `COLUMN_2`)  |
| 13 | root      | localhost | NULL      | Query   |    0 | NULL   | show processlist                                  |
+----+-----------+-----------+-----------+---------+------+--------+---------------------------------------------------+
2 rows in set (0.00 sec)

Thread数を確認するには?

show global status like ‘Thread_%’

lock待ち数を確認するには?

select t_b.trx_mysql_thread_id blocking_id,
       t_w.trx_mysql_thread_id requesting_id,
       p_b.HOST blocking_host,
       p_w.HOST requesting_host,
       l.lock_table lock_table,
       l.lock_index lock_index,
       l.lock_mode lock_mode,
       p_w.TIME seconds,
       p_b.INFO blocking_info,
       p_w.INFO requesting_info
from information_schema.INNODB_LOCK_WAITS w,
       information_schema.INNODB_LOCKS l,
       information_schema.INNODB_TRX t_b,
       information_schema.INNODB_TRX t_w,
       information_schema.PROCESSLIST p_b,
       information_schema.PROCESSLIST p_w
where w.blocking_lock_id = l.lock_id and
      w.blocking_trx_id = t_b.trx_id  and
      w.requesting_trx_id = t_w.trx_id  and
      t_b.trx_mysql_thread_id = p_b.ID  and
      t_w.trx_mysql_thread_id = p_w.ID
order by requesting_id, blocking_id

目次

前のトピックへ

見間違いやすいアルファベット

次のトピックへ

Python

このページ

inserted by FC2 system