mysqlperformance
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mysqlperformance [2019/08/05 15:33] – [Performance Schema Scripts] z0hpvk | mysqlperformance [2025/03/08 22:24] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| <code SQL> | <code SQL> | ||
| -- Unused Indexes | -- Unused Indexes | ||
| + | select * from sys.schema_unused_indexes; | ||
| + | |||
| select object_schema, | select object_schema, | ||
| from performance_schema.table_io_waits_summary_by_index_usage | from performance_schema.table_io_waits_summary_by_index_usage | ||
| where index name is not null and count_star = 0 | where index name is not null and count_star = 0 | ||
| order by object_schema, | order by object_schema, | ||
| + | |||
| + | -- Queries not using Indexes | ||
| + | SELECT THREAD_ID TID, SUBSTR(SQL_TEXT, | ||
| + | | ||
| + | FROM performance_schema.events_statements_history | ||
| + | WHERE NO_INDEX_USED=1 OR NO_GOOD_INDEX_USED=1; | ||
| + | |||
| + | -- Queries using Full Table Scans | ||
| + | SELECT query, db, total_latency, | ||
| + | FROM sys.statements_with_full_table_scans | ||
| + | WHERE db not in (' | ||
| + | ORDER BY last_seen DESC limit 50; | ||
| -- Process List | -- Process List | ||
| Line 68: | Line 82: | ||
| select user, | select user, | ||
| from sys.user_summary_by_statement_type limit 100; | from sys.user_summary_by_statement_type limit 100; | ||
| + | | ||
| + | -- Active Queries | ||
| + | SELECT CONCAT_WS( | ||
| + | '','# | ||
| + | ,'# User@Host: ', | ||
| + | ,'# Schema: ', | ||
| + | ,'# Query_time: ', | ||
| + | ,'# Tmp_tables: ', | ||
| + | ,'# Full_scan: ', | ||
| + | , t.PROCESSLIST_INFO,';' | ||
| + | FROM performance_schema.events_statements_history s | ||
| + | JOIN performance_schema.threads t using(thread_id) | ||
| + | WHERE t.TYPE = ' | ||
| + | AND t.PROCESSLIST_INFO IS NOT NULL | ||
| + | AND t.PROCESSLIST_ID != connection_id() | ||
| + | ORDER BY t.PROCESSLIST_TIME desc; | ||
| </ | </ | ||
mysqlperformance.1565019211.txt.gz · Last modified: (external edit)
