PostgreSQL · SQL
SELECT schemaname || '.' || sequencename AS sequence_name,
last_value,
max_value,
ROUND(100.0 * last_value / max_value, 2) AS used_pct
FROM pg_sequences
WHERE last_value IS NOT NULL
AND last_value > max_value * 0.8
ORDER BY used_pct DESCThis query is part of the "PostgreSQL health" pack: connect the database in DataRunner and install the whole pack — queries, dashboard and checks — at once.
- Check that ships with it: No sequence past 80% of its range