timetz storage vs timestamptz

Started by Jim C. Nasbyover 19 years ago3 messages
#1Jim C. Nasby
jim@nasby.net

Why is it timestamptz can store a date and time to 1 microsecond in 8
bytes but a timetz needs 12 to store just the time to 1 microsecond?
--
Jim Nasby jim@nasby.net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jim C. Nasby (#1)
Re: timetz storage vs timestamptz

"Jim C. Nasby" <jim@nasby.net> writes:

Why is it timestamptz can store a date and time to 1 microsecond in 8
bytes but a timetz needs 12 to store just the time to 1 microsecond?

It's tracking the timezone explicitly ... something that timestamptz
really ought to do too.

regards, tom lane

#3Jim Nasby
jimn@enterprisedb.com
In reply to: Tom Lane (#2)
Re: timetz storage vs timestamptz

On Oct 3, 2006, at 5:32 PM, Tom Lane wrote:

"Jim C. Nasby" <jim@nasby.net> writes:

Why is it timestamptz can store a date and time to 1 microsecond in 8
bytes but a timetz needs 12 to store just the time to 1 microsecond?

It's tracking the timezone explicitly ... something that timestamptz
really ought to do too.

Wow, the docs are totally unclear on that. I believe that explains
bug 2661.

Yes, it would be nice to store the timezone in timestamptz or an
equivalent, but there's also a use for the current behavior. In many
cases, you don't care what the original timezone was; you just want
to make sure that everything is getting stored in UTC (and then
converted to your local timezone on the way back out).

I'm thinking time[stamp], time[stamp]tz (which should do what timetz
does), and time[stamp]utc (doing what timestamptz does).

In the meantime I'll try and clarify the docs on this.
--
Jim Nasby jimn@enterprisedb.com
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)