View monitoring_active_locks
Monitoring active database connections and their lock state.
Columns
| Column Name | datatype | Description |
|---|---|---|
| pid | integer | The process id of the backend, needed in case a connection should be terminated with the function pg-terminate_backend(pid). For details see SERVER SIGNALING FUNCTIONS. |
| state | text | The current state of the connection. |
| database_name | name | The database name in which the queries have been executed. |
| rolename | name | The role/user who executed the queries. |
| application_name | text | The name of the application, could be empty if not set by a client. |
| client_address | inet | The clients IP address. |
| query_start | timestamp with time zone | The timestamp of the start of the query. |
| query_age | interval | How long the query is already running. |
| wait_event_type | text | The type of event for which the backend is waiting, if any; otherwise NULL, for details see WAIT EVENT TABLE. |
| wait_event | text | Wait event name if backend is currently waiting, otherwise NULL. For details see WAIT EVENT ACTIVITY TABLE and WAIT EVENT TIMEOUT TABLE |
| locktype | text | The type of the lockable object: relation, extend, frozenid, page, tuple, transactionid, virtualxid, spectoken, object, userlock, advisory, or applytransaction, see Wait Events of Type Lock. |
| mode | text | The name of the lock mode held or desired by this process. For details see TABLE LEVEL LOCKS and SERIALIZABLE ISOLATION LEVEL. |
| query | text | This is the SQL source of the query. |
Example
SELECT *
FROM monitoring_active_locks;
| pid | state | database_name | rolename | application_name | client_address | query_start | query_age | wait_event_type | wait_event | locktype | mode | query |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 495301 | active | pgsql_tweaks_test | stefanie | DBeaver 25.1.5 - SQLEditor | 127.0.0.1 | 2025-08-22 11:34:25.448 +0200 | -00:00:00.002829 | relation | AccessShareLock | SELECT * FROM monitoring_active_locks | ||
| 495301 | active | pgsql_tweaks_test | stefanie | DBeaver 25.1.5 - SQLEditor | 127.0.0.1 | 2025-08-22 11:34:25.448 +0200 | -00:00:00.002829 | virtualxid | ExclusiveLock | SELECT * FROM monitoring_active_locks |