PostgreSQL Connection Statistics
pg_connection_statsShow connection statistics grouped by database, user, application, or state to monitor pool utilization and detect idle connections or leaks.
Instructions
Show a summary of current connections grouped by database, user, application, and state.
Useful for monitoring connection pool utilization, finding idle connections, and detecting connection leaks from specific applications.
Args:
group_by: Group connections by 'database', 'user', 'application', or 'state' (default: state)
database: Filter to a specific database (optional)
response_format: Output format
Returns: JSON: { summary: ConnectionStat[], total_connections: number, max_connections: string, usage_pct: number } Markdown: grouped connection count with waiting and max idle age
Note: Excludes the MCP server's own backend connection from counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| group_by | No | Group connections by 'database', 'user', 'application', or 'state' | state |
| database | No | Filter to specific database (optional) | |
| response_format | No | Output format: 'markdown' for human-readable, 'json' for machine-readable | markdown |