Transaction Monitoring
Transaction Monitoring is a SQL statement in the Transactions category. Monitor active/long-running transactions to detect blocking, deadlocks, and transaction log issues. The syntax is SELECT * FROM pg_stat_activity WHERE state = 'idle in transaction';. It returns transaction monitoring info. A typical example: -- PostgreSQL: view active transactions SELECT pid, datname, usename, state, query_start, wait_event_type, query FROM pg_stat_activity WHERE state != 'idle' ORDER BY query_start; -- SQL Server: view open transactions SELECT transaction_id, name, transaction_begin_time, transaction_type, transaction_state FROM sys.dm_tran_active_transactions; -- MySQL: show processlist SHOW FULL PROCESSLIST; -- Look for transactions in 'LOCK WAIT' state -- Kill long-running transaction: -- PostgreSQL: SELECT pg_terminate_backend(pid); -- SQL Server: KILL spid; -- MySQL: KILL connection_id; A close relative is BEGIN / START TRANSACTION, which begins a new transaction. Changes made within are invisible to others until COMMIT. A close relative is COMMIT, which saves all changes made in the current transaction permanently.