91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL 5.7 performance_schema庫和sys庫常用SQL

發布時間:2020-08-10 08:49:48 來源:ITPUB博客 閱讀:241 作者:chenfeng 欄目:MySQL數據庫

performance_schema庫常用SQL:

查看沒有主鍵的表:

    SELECT DISTINCT t.table_schema, t.table_name

      FROM information_schema.tables AS t

      LEFT JOIN information_schema.columns AS c ON t.table_schema = c.table_schema 

AND t.table_name = c.table_name AND c.column_key = "PRI"

     WHERE t.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema')

       AND c.table_name IS NULL AND t.table_type != 'VIEW';


例如:

mysql> SELECT DISTINCT t.table_schema, t.table_name

    ->       FROM information_schema.tables AS t

    ->       LEFT JOIN information_schema.columns AS c ON t.table_schema = c.table_schema 

AND t.table_name = c.table_name  AND c.column_key = "PRI"

    ->      WHERE t.table_schema NOT IN ('information_schema', 'mysql', 'performance_schema')

    ->        AND c.table_name IS NULL AND t.table_type != 'VIEW';


+--------------+---------------------------+

| table_schema | table_name                |

+--------------+---------------------------+

| S85          | dsf                       |

| test         | innodb_lock_monitor       |

| test         | innodb_monitor            |

| test         | innodb_table_monitor      |

| test         | innodb_tablespace_monitor |

| zhwp102      | t_orgpriority             |

| zhwp102      | t_task_ext                |

| zhwp102      | t_web_common              |

| zhwp111      | t_orgpriority             |

| zhwp111      | t_task_ext                |

| zhwp111      | t_web_common              |

| zhwp111      | t_weibo                   |

| zhwp_prod    | t_orgpriority             |

| zhwp_prod    | t_task_ext                |

| zhwp_prod    | t_web_common              |

| zhwp_prod    | t_weibo                   |

| zhwpzj111    | t_orgpriority             |

| zhwpzj111    | t_task_ext                |

| zhwpzj111    | t_web_common              |

| zhwpzj111    | t_weibo                   |

+--------------+---------------------------+

20 rows in set (1 min 27.55 sec)


沒有主鍵:

mysql> desc S85.dsf;    

+------------+----------------------+------+-----+-------------------+-------+

| Field      | Type                 | Null | Key | Default           | Extra |

+------------+----------------------+------+-----+-------------------+-------+

| sourceDay  | date                 | YES  |     | NULL              |       |

| sourceTime | datetime             | NO   |     | CURRENT_TIMESTAMP |       |

| affections | smallint(5) unsigned | NO   |     | 1                 |       |

+------------+----------------------+------+-----+-------------------+-------+

3 rows in set (0.00 sec)


查看是誰創建的臨時表


    SELECT user, host, event_name, count_star AS cnt, sum_created_tmp_disk_tables AS tmp_disk_tables, 

sum_created_tmp_tables AS tmp_tables

      FROM performance_schema.events_statements_summary_by_account_by_event_name

     WHERE sum_created_tmp_disk_tables > 0

        OR sum_created_tmp_tables > 0 ;



沒有正確關閉數據庫連接的用戶

    SELECT ess.user, ess.host

         , (a.total_connections - a.current_connections) - ess.count_star as not_closed

         , ((a.total_connections - a.current_connections) - ess.count_star) * 100 /

           (a.total_connections - a.current_connections) as pct_not_closed

      FROM performance_schema.events_statements_summary_by_account_by_event_name ess

      JOIN performance_schema.accounts a on (ess.user = a.user and ess.host = a.host)

     WHERE ess.event_name = 'statement/com/quit'

       AND (a.total_connections - a.current_connections) > ess.count_star ;


DDL元數據鎖跟蹤

1.打開跟蹤:

UPDATE performance_schema.setup_instruments SET ENABLED = 'YES' WHERE 

NAME = 'wait/lock/metadata/sql/mdl';

UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE

 NAME = 'global_instrumentation';

2.查詢metadata lock:

select  * from performance_schema.metadata_locks;

select  * from performance_schema.metadata_locks where LOCK_STATUS like 'PENDING%';

select ID from information_schema.processlist where Info  like '%20190416%' \G

SELECT OBJECT_TYPE,OBJECT_SCHEMA,OBJECT_NAME,LOCK_STATUS,processlist_id 

    FROM performance_schema.metadata_locks mdl

    INNER JOIN performance_schema.threads thd ON mdl.owner_thread_id = thd.thread_id 

    WHERE processlist_id <> @@pseudo_thread_id;


3.關閉跟蹤:

UPDATE performance_schema.setup_instruments SET ENABLED = 'NO' WHERE 

NAME = 'wait/lock/metadata/sql/mdl';    

   

DDL執行進度跟蹤

1.打開跟蹤:

UPDATE performance_schema.setup_instruments SET ENABLED = 'YES' WHERE NAME LIKE 'stage/innodb/alter%';

UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%stages%';

2.查看DDL執行進度:

SELECT EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED,(WORK_COMPLETED/WORK_ESTIMATED)*100 

as COMPLETED FROM performance_schema.events_stages_current;


sys庫常用SQL:

查看表訪問量

select table_schema,table_name,sum(io_read_requests+io_write_requests) io from sys.schema_table_statistics 

group by table_schema,table_name order by io desc limit 10;


查看數據庫連接情況

select * from sys.processlist \G

select * from sys.session limit 10 \G

select * from sys.x$processlist \G

select * from sys.x$session \G


查看冗余索引

select table_schema,table_name,redundant_index_name,redundant_index_columns,dominant_index_name,

dominant_index_columns  from sys.schema_redundant_indexes;


查看未使用索引

select * from sys.schema_unused_indexes;


表自增ID監控

select * from sys.schema_auto_increment_columns limit 10;


查看實際消耗磁盤IO的文件

select file,avg_read+avg_write as avg_io from sys.io_global_by_file_by_bytes order by avg_io desc limit 10;


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

大港区| 蒙山县| 区。| 保亭| 常德市| 武夷山市| 鄢陵县| 雷山县| 和顺县| 宜宾县| 义乌市| 汶川县| 呈贡县| 姜堰市| 乌拉特中旗| 海宁市| 滕州市| 东光县| 绍兴县| 卫辉市| 麻城市| 祥云县| 康定县| 大理市| 齐河县| 嵊州市| 新疆| 阳东县| 花垣县| 奎屯市| 时尚| 潮安县| 南平市| 炎陵县| 双牌县| 龙江县| 从江县| 东光县| 天台县| 交口县| 邹平县|