postgresql_16:3.10.3 Explicit Locking
PostgreSQL 16 > The SQL Language > Concurrency Control > Explicit Locking
PostgreSQL provides various lock modes to control concurrent access to data in tables. These modes can be used for application-controlled locking in situations where MVCC does not give the desired behavior. Also, most PostgreSQL commands automatically acquire locks of appropriate modes to ensure that referenced tables are not dropped or modified in incompatible ways while the command executes. (For example, TRUNCATE cannot safely be executed concurrently with other operations on the same table, so it obtains an ACCESS EXCLUSIVE lock on the table to enforce that.)
To examine a list of the currently outstanding locks in a database server, use the pg_locks (see postgresql_16:8.3.12) system view. For more information on monitoring the status of the lock manager subsystem, refer to (see postgresql_16:4.13).
Subsections
- postgresql_16:3.10.3.1 Table-Level Locks
- postgresql_16:3.10.3.2 Row-Level Locks
- postgresql_16:3.10.3.3 Page-Level Locks
- postgresql_16:3.10.3.4 Deadlocks
- postgresql_16:3.10.3.5 Advisory Locks