Audit sequences
audit_sequencesCheck PostgreSQL sequences for approaching overflow by comparing last_value to max_value against warning and critical thresholds, returning at-risk sequences sorted by usage percentage to prevent serial ceiling errors.
Instructions
Flag sequences nearing their ceiling — serial / identity / explicit sequences whose last_value / max_value exceeds warning_pct (default 80) or critical_pct (default 95). Sequence overflow is catastrophic and silent until the next nextval() raises 'reached maximum value' — the int4 serial ceiling (2^31-1) is hit far more often than expected. Pure read; available=false on PG < 10 (no pg_sequences). Returns an object with available, total_examined, warning_pct, critical_pct, detail, and sequences (at-risk only, sorted by used_pct desc — each with schema, sequence, last_value, max_value, used_pct, remaining, status).
Example: audit_sequences(warning_pct=80, critical_pct=95)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| warning_pct | No | ||
| critical_pct | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detail | No | ||
| available | Yes | ||
| sequences | Yes | ||
| warning_pct | Yes | ||
| critical_pct | Yes | ||
| total_examined | Yes |