Re: how to add seconds to a TimestampTz - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: how to add seconds to a TimestampTz
Date
Msg-id 20070315130639.GA5645@alvh.no-ip.org
Whole thread Raw
In response to Re: how to add seconds to a TimestampTz  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> > Is there a better way than going to time_t and back?
> 
> Isn't the standard SQL-level locution
>     timestamptz + numeric_value * '1 second'::interval
> ?  I'm not sure what would be the most convenient realization
> of this at the C level, but please stay away from time_t ...

Yes, it is, but we would have to be calling interval input,
interval-times-integer, then interval-plus-timestamp, each time we
scheduled a worker (to calculate the "time of next worker start"), which
sounds like too much work ... an idea would be to store the result of
interval input and multiplication, and recalculate each time we got
SIGHUP.

But then, maybe this is premature optimization on my part.  I'll write
it in the natural form for now, and then we'll see if we should rewrite
it; and then, maybe it's easier to write something equivalent to
TimestampDifference ...

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


pgsql-hackers by date:

Previous
From: Grzegorz Jaskiewicz
Date:
Subject: [RFC] CLUSTER VERBOSE
Next
From: Grzegorz Jaskiewicz
Date:
Subject: Re: how to add seconds to a TimestampTz