List current locks
Oracle
SELECT s.sid, s.serial#, l.type, DECODE(l.lmode,0,'None',1,'Null',2,'Row-S',3,'Row-X',4,'Share',5,'S/Row-X',6,'Exclusive') AS lmode, o.object_name, s.username, s.blocking_session
FROM v$lock l
JOIN v$session s ON s.sid = l.sid
LEFT JOIN v$locked_object lo ON lo.session_id = l.sid
LEFT JOIN dba_objects o ON o.object_id = lo.object_id
ORDER BY s.sid;Shows active locks and the blocking session (blocking_session) via v$lock and v$locked_object.
PostgreSQL
SELECT l.locktype, l.mode, l.granted, a.pid, a.usename, a.state, a.wait_event_type, a.query
FROM pg_locks l
JOIN pg_stat_activity a ON a.pid = l.pid
WHERE l.pid <> pg_backend_pid()
ORDER BY l.granted, a.pid;Joins pg_locks with pg_stat_activity; rows with granted=false show waiting (blocked) locks.
MySQL
SELECT ENGINE, OBJECT_SCHEMA, OBJECT_NAME, LOCK_TYPE, LOCK_MODE, LOCK_STATUS, THREAD_ID
FROM performance_schema.data_locks;
-- For waiters: SELECT * FROM performance_schema.data_lock_waits;performance_schema.data_locks lists current InnoDB locks, and data_lock_waits lists the wait relationships.
SQL Server
SELECT tl.resource_type, tl.resource_database_id, tl.request_mode, tl.request_status, tl.request_session_id, es.login_name, er.blocking_session_id
FROM sys.dm_tran_locks tl
LEFT JOIN sys.dm_exec_sessions es ON es.session_id = tl.request_session_id
LEFT JOIN sys.dm_exec_requests er ON er.session_id = tl.request_session_id
ORDER BY tl.request_session_id;sys.dm_tran_locks shows current lock requests; those with request_status = WAIT are blocked requests.
MongoDB
db.currentOp({ "$or": [ { "waitingForLock": true }, { "locks": { "$exists": true } } ] })db.currentOp shows operations waiting for a lock (waitingForLock) and operations holding locks; MongoDB locks at the document/collection level, not the row level.
Redis
# Not applicable: Redis has no row/table lock concept; commands run sequentially on a single thread. For blocking analysis, use the SLOWLOG and LATENCY commands.Because Redis is single-threaded, there is no traditional lock list.
Elasticsearch
GET _cluster/pending_tasksElasticsearch has no row locks; this lists the cluster change tasks queued on the master (pending tasks).