ORACLE/SQLSQVER/MYSQL模式
powershell
SELECT
CASE
WHEN xact_start IS NULL THEN '长连接'
ELSE '长事务'
END as backend_type,
pid,
sys_blocking_pids(pid) as blocking_pids,
usename,
query,
xact_start,
query_start,
state,
now() as current_time,
*
FROM sys_stat_activity
WHERE state <> 'idle'
AND (
query_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
OR
xact_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
);
POSTGRESQL模式
powershell
SELECT
CASE
WHEN xact_start IS NULL THEN '长连接'
ELSE '长事务'
END as backend_type,
pid,
pg_blocking_pids(pid) as blocking_pids,
usename,
query,
xact_start,
query_start,
state,
now() as current_time,
*
FROM pg_stat_activity
WHERE state <> 'idle'
AND (
query_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
OR
xact_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
);