On the contrary, timestamp has no sense of timezone and applications must taken care of this process(build the wheel) by themselves. When handling timestamptz, Postgres converts the datetime into UTC automatically before storing and converts back into session timezone during querying. Actually, timestamptz and timestamp take the same amount of disk space(8 bytes), has the same range(4713 BC~294276 AD), and has the same resolution of 1 microsecond. It’s a common misunderstanding that timestamptz takes more disk spaces than timestamp because of the need to store timezone info. timestamp without time zone, aka timestamp, not timezone-aware.Ĭonclusion first, Postgres recommends that timestamptz( timestamp with time zone) should be used under most circumstances and you should not store time as UTC in timestamp.timestamp with time zone, aka timestamptz, timezone-aware.Per SQL standard, Postgres implements and provides two timestamp types: The time is uniquely determined by year, month, day, hour, minute and second, given timezone is specified. We are living in a four-dimension space of length, width, height and time. This article briefs them, talks about gotchas and recommendations like why not store every datetime in UTC. Postgres provides five datetime data types, including timestamp/ timestamp with time zone, date, time, interval and time range( tsrange, tstzrange, daterange). Life would be much easier if its strength is well utilized. PostgreSQL(or Postgres) is a great database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |