-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueries_for_monitoring
46 lines (45 loc) · 1.82 KB
/
Queries_for_monitoring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--Monitoring Wait Events- To see the summary of wait events in your database:
'''
SELECT *
FROM performance_schema.events_waits_summary_global_by_event_name
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 10;
'''
--Monitoring SQL Statement Execution - To see how long different SQL statements take to execute, analyze their total execution time, average time, and count.
'''
SELECT *
FROM performance_schema.events_statements_summary_global_by_event_name
ORDER BY COUNT_STAR DESC
LIMIT 10;
'''
--Monitoring Resource Usage by User -To see resource usage by user,useful to identify which users are consuming the most resources.
'''
SELECT USER, COUNT_STAR, SUM_TIMER_WAIT
FROM performance_schema.events_statements_summary_by_user
ORDER BY SUM_TIMER_WAIT DESC;
'''
--Monitoring Table I/O- To get I/O wait statistics by table, shows which tables are causing the most I/O waits. High I/O wait times can indicate issues with storage performance or table structure.
'''
SELECT *
FROM performance_schema.table_io_waits_summary_by_table
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 10;
'''
--Monitoring Locks- To check for current locks held by transactions,shows all currently granted locks, which can help diagnose deadlocks or contention issues.
'''
SELECT *
FROM performance_schema.events_statements_current;
'''
--Monitoring Current Statements- To see currently running statements, shows all currently executing SQL statements, which is helpful for real-time monitoring.
'''
SELECT *
FROM performance_schema.events_statements_current;
'''
--Analyzing Histograms of Query Execution Times-To see the distribution of execution times for a specific query,provides a history of long-running SELECT statements, which can help identify performance patterns.
'''
SELECT *
FROM performance_schema.events_statements_history_long
WHERE SQL_TEXT LIKE '%SELECT%'
ORDER BY EVENT_ID DESC
LIMIT 100;
'''