Re: storing TZ along timestamps

From: Jim Nasby <jim(at)nasby(dot)net>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Christopher Browne <cbbrowne(at)gmail(dot)com>, Steve Crawford <scrawford(at)pinpointresearch(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: storing TZ along timestamps
Date: 2011-06-03 03:58:33
Message-ID: 0B9D4F4F-CDCD-49C2-A926-CF37756AB7C5@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jun 2, 2011, at 7:48 PM, Jeff Davis wrote:
> On Thu, 2011-06-02 at 20:28 -0400, Robert Haas wrote:
>> But that doesn't seem like enough, because if someone adds '1 day',
>> knowing the offset isn't sufficient to figure out the answer. You
>> have to know where the DST boundary is.
>
> Good point, I guess the timezone itself needs to be stored. That's a
> little unfortunate, because timezones are somewhat of a moving target
> (which I think was Tom's point).
>
> That means that we'd need an entire history (and future?) of timezone
> definitions, and apply the timezone definition as of the associated
> timestamp to get the offset. Or, should we apply the timezone definition
> as of the "real" time the value was entered?

As someone else mentioned, timestamptz suffers the exact same problems.

I'm torn between whether the type should store the original time or the original time converted to GMT. I believe you would have the most accuracy if you stored the original time... but then indexing becomes problematic. I don't know if this data quality issue can be solved by anything short of somehow storing the actual timezone rule that was in place when the data was set.

Speaking of input; someone asked what timezone should be used as the "original" timezone. We should use whatever timezone was passed in with the value, and if one wasn't passed in we should use whatever the timezone GUC is set to (I'm assuming that's what timestamptz does).
--
Jim C. Nasby, Database Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-06-03 04:15:49 Re: Estimating total amount of shared memory required by postmaster
Previous Message fanngyuan 2011-06-03 02:52:47 how to get the max value in an array