Monitor running/recent SQL in real time
Oracle
SET LONG 1000000 LONGCHUNKSIZE 1000000 LINESIZE 250 PAGESIZE 0
SELECT DBMS_SQLTUNE.REPORT_SQL_MONITOR(sql_id=>'&sql_id', type=>'TEXT') AS report FROM dual;
-- or: SELECT sql_id, status, elapsed_time FROM v$sql_monitor WHERE status='EXECUTING';Real-Time SQL Monitoring shows long/parallel queries live (Tuning Pack).
PostgreSQL
SELECT pid, now()-query_start AS dur, state, wait_event, query
FROM pg_stat_activity WHERE state='active' ORDER BY query_start;With auto_explain, plans of slow queries can be logged automatically.
MySQL
SELECT thread_id, event_name, timer_wait/1e9 AS ms, sql_text
FROM performance_schema.events_statements_current;events_statements_current shows the statements currently running.
SQL Server
SELECT r.session_id, r.status, r.wait_type, r.percent_complete, t.text
FROM sys.dm_exec_requests r JOIN sys.dm_exec_sessions s ON s.session_id = r.session_id CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE s.is_user_process = 1;'Live Query Statistics' in SSMS shows plan progress live.
MongoDB
db.currentOp({ active: true, secs_running: { $gt: 1 } })Shows long-running operations live; they can be terminated with killOp.
Redis
MONITORStreams ALL commands live — affects performance in production, use it only briefly. Prefer SLOWLOG instead.
Elasticsearch
GET _tasks?detailed=true&group_by=parentsShows running tasks live; a long task is cancelled with POST _tasks/<id>/_cancel.