Re: Range-Types in 9.2

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Jeff Davis'" <pgsql(at)j-davis(dot)com>, "'Andreas Kretschmer'" <andreas(at)a-kretschmer(dot)de>
Cc: "'pg-general'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Range-Types in 9.2
Date: 2012-08-06 18:09:16
Message-ID: 00af01cd73fe$97d29460$c777bd20$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of Jeff Davis
> Sent: Monday, August 06, 2012 1:52 PM
> To: Andreas Kretschmer
> Cc: pg-general
> Subject: Re: [GENERAL] Range-Types in 9.2
>
> On Fri, 2012-08-03 at 10:42 -0700, Jeff Davis wrote:
> > On Fri, 2012-08-03 at 17:06 +0200, Andreas Kretschmer wrote:
> > > great feature, but i can't find a TIMERANGE, i want to store
> > > time-ranges, for instance [10:00:00,16:00:00), how can i do that?
> >
> > CREATE TYPE timerange AS RANGE ( subtype = time );
> >
> > That's the simple answer. I believe we discussed including this as a
> > built-in range type at some point, but decided against it. I can't
> > remember the reason right now.
>
> Time of day is a cycle (I forget who pointed this out), so a limit of
> 24:00:00 is fairly restrictive. It happens that daytime ranges like
> [14:00,15:00) are more common; but it doesn't seem unreasonable to say
> [22:00,02:00) either.
>
> So, an interpretation where time of day has a total order is only useful really
> for a daytime schedule (which is still useful, but perhaps not general enough
> to include in core). We might be able to make it work as ranges within a 24-
> hour cycle, but that will require more thought.
>
> Regards,
> Jeff Davis
>

Because hours are based upon a zero-cycle it is possible to define a time range as thus:

Start: 15:00
End: 03:00
Maximum: 24:00
Minimum: 00:00 { More generalized, can reset to any value }
Iterations: 2

Basically a "cyclical range"...

The question becomes in what situations would this be more useful than an explicit starting and ending timestamp (with date).

It would likely just be easier to create a custom "time" variant that allows for values greater than "24:00" and less-than "00:00" and then create a range from that.

Maybe name it "relativetime"...

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2012-08-06 18:30:15 Re: How to analyze load average ?
Previous Message Jeff Davis 2012-08-06 17:51:48 Re: Range-Types in 9.2