Client Manager Database
Long running transactions
If you encounter this alert, it means that there are transactions that have been running for a long time. This can be caused by various factors such as heavy load on the database, inefficient queries, or locks on the database. To find out what the transaction is you can use the following query:
SELECT * FROM pg_stat_activity WHERE state = 'active' AND now() - query_start > interval '24 hours';
This query will show you all the active transactions that have been running for more than 24 hours. You can adjust the time interval as needed. Once you identify the long-running transactions, you can choose to terminate them if they are not needed or investigate further to understand why they are taking so long. To terminate a transaction, you can use the following command:
SELECT pg_terminate_backend(pid);
Replace pid with the process ID of the transaction you want to terminate.