PG Bug reporting form <noreply@postgresql.org> writes:
> timestamptz casting on year 2022 values returns a precision of one
> microsecond (as it is expected).
> As the year goes up, the precision goes down as the script below will show
> for years 2022, 23621, 2713, 4022, and 8022.
The issue here is not with the timestamp, nor even with the extract().
It's with your use of to_timestamp(), which takes float8, which has
limited precision. The precision is disappearing in the implicit
cast to float8.
Prior to v14, there was also an issue with extract() returning float8,
but nowadays it returns numeric. If you look directly at the extract()
results you'll see no precision is lost.
Maybe we should invent a variant of to_timestamp that takes numeric, but
the use-case seems pretty niche ...
regards, tom lane