Re: how to add seconds to a TimestampTz

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: how to add seconds to a TimestampTz
Date: 2007-03-15 13:06:39
Message-ID: 20070315130639.GA5645@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Grzegorz Jaskiewicz 2007-03-15 13:31:03 Re: how to add seconds to a TimestampTz
Previous Message Grzegorz Jaskiewicz 2007-03-15 12:40:30 [RFC] CLUSTER VERBOSE