Hi @sql user , welcome to Microsoft Q&A forum.
You can run below query to see the count of total connections state-wise:
SELECT count(*),state FROM pg_stat_activity GROUP BY 2;
If the count is greater than 600 overall, you can run below query to clean up the idle connections:
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'postgres' AND pid <> pg_backend_pid() AND state in ('idle');
Please note the datname is the database where we want to check the query.
Please let us know if this helps or else we can discuss further on the same.
Referenced Article:
https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/connection-handling-best-practice-with-postgresql/ba-p/790883
https://stackoverflow.com/questions/30931683/how-to-kill-the-idle-connection-in-postgresql
----------
If answer helps, you can mark it as 'Accept Answer'