> Sorry, I could have been clearer - pg_stat_activity is what I'm looking > at - I'm recording connection info from here every 15 seconds (from a > superuser account so I don't get locked out). It never peaks above 300 > (in fact when the incident happens no new connections can come in so it > falls to around 100) - yet I'm seeing the log lines claim that I'm still > hitting 597 (600 - 3 reserved).
What is the query you are using against pg_stat_activity?
For general counts ad-hoc we just use:
SELECT count(*) FROM pg_stat_activity
The monitoring system runs:
SELECT CASE WHEN usename IS NOT NULL THEN usename ELSE 'SYSTEM' END as role,
datname AS database, state, wait_event, count(*) AS connection FROM pg_stat_activity GROUP BY 1,2,3,4
The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.