-
Notifications
You must be signed in to change notification settings - Fork 113
/
mysql_sessions.sql
53 lines (51 loc) · 1.03 KB
/
mysql_sessions.sql
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
47
48
49
50
51
52
53
--
-- Author: Hari Sekhon
-- Date: 2020-08-06 02:13:54 +0100 (Thu, 06 Aug 2020)
--
-- vim:ts=4:sts=4:sw=4:et:filetype=sql
--
-- https://github.com/HariSekhon/SQL-scripts
--
-- License: see accompanying Hari Sekhon LICENSE file
--
-- If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
--
-- https://www.linkedin.com/in/HariSekhon
--
-- MySQL sessions
--
-- Requires MySQL 5.7+
-- Requires MariaDB N/A
--
-- Tested on MySQL 5.7, 8.0
--
-- sys doesn't exist in MySQL <= 5.6 or MariaDB 10.5
SELECT
user,
db,
program_name,
command,
state,
time,
current_statement,
current_memory,
progress,
lock_latency,
rows_examined,
rows_sent,
rows_affected,
tmp_tables,
tmp_disk_tables,
full_scan,
last_statement,
last_statement_latency,
last_wait,
last_wait_latency,
trx_latency,
trx_state
FROM
sys.session
WHERE
user <> 'sql/event_scheduler'
ORDER BY
current_memory DESC;