May 2018
Intermediate to advanced
576 pages
30h 25m
English
SELECT t.schemaname || '.' || t.relname AS tablename, l.pid, l.granted FROM pg_locks l JOIN pg_stat_user_tables t ON l.relation = t.relid;
tablename | pid | granted-----------+-------+--------- db.x | | t db.x | 27289 | f(2 rows)
The preceding example shows a lock on the db.x table, which has no process associated with it.
If you need to remove a particular prepared transaction, you can refer to the Removing old prepared transactions recipe in Chapter 9, Regular Maintenance.