Diagnostic Queries
Symptoms
An interval computation or value exceeded the representable range. PostgreSQL raises SQLSTATE 22015 (interval_field_overflow).
- Interval arithmetic overflowed the type’s range.
- Common with multiplying intervals by large factors.
- Also seen adding many large intervals.
What the server log shows
ERROR: interval out of range
Why PostgreSQL raises this — what the manual says
Section 8.5.4 Interval Input:
“Internally, interval values are stored as three integral fields: months, days, and microseconds.”
Intervals store months/days/microseconds within fixed limits. A computation producing a value beyond those limits cannot be represented and PostgreSQL reports 22015.
Common causes
- Multiplying an interval by a very large number.
- Summing many large intervals.
- Constructing an interval with extreme field values.
How to fix it
- Keep interval magnitudes within the supported range.
- Recompute using smaller units or split the calculation.
- Validate factors before scaling intervals.
Related & next steps
Reference: PostgreSQL 18 Section 8.5 “Date/Time Types”.
Thanks — noted. This helps keep the database accurate.