Sequences — Wraparound Risk & Ownership
Find sequences nearing INT4 wraparound + sequences without an owning column (orphans).
An integer primary key fed by a BIGSERIAL sequence has 2.1 billion values before wraparound. At 1000 inserts per second that's 25 days. BIGINT sequences are safe for ~292 billion years, which is fine for any application you're going to be alive to see. MonPG flags any sequence whose last_value exceeds 80% of its data type's max — and the warning typically lands months in advance, not at the last minute.
What this page shows
| Column | Meaning |
|---|---|
| Sequence name | Schema-qualified name. |
| Owned by | Table.column the sequence backs. NULL means orphan, candidate for DROP. |
| Data type | integer / bigint / smallint. |
| last_value | Current sequence value. |
| Max value | Type-determined — 2.1B for integer, 9.2 quintillion for bigint. |
| Used % | last_value / max_value. ⚠ when over 80%, 🔴 when over 95%. |
| Cache | Sequence cache size, default 1. |
What to do about a warning
Wraparound risk on an integer PK has one safe fix: ALTER TABLE … ALTER COLUMN id TYPE bigint. On a large table this is heavy — table rewrite, index rebuilds, the works. Plan with pg_repack or the logical-replica swap pattern; don't try this in a Tuesday-afternoon "quick fix."
Orphan sequences are usually leftover from dropped tables and safe to DROP SEQUENCE after confirming no application code still references them. Worth doing eventually because they show up in dump output and add noise.