Search code examples
sqlpostgresqltransactions

PostgreSQL List of Transactions


Is there a list of transactions that I can see that have not been committed yet?

Example:

Begin;
delete
from table
where column IS NOT NULL;

I have not committed this yet. I would like to see this and every other transaction taking place that has not been committed.


Solution

  • You can see the list of database session that have an open transaction along with the transaction ID in pg_stat_activity:

    SELECT pid, backend_xid
    FROM pg_stat_activity
    WHERE backend_xid IS NOT NULL;
    

    You don't say what you want that information for ...