Re: using possibly null timestamptz columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: James Cloos <cloos(at)jhcloos(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: using possibly null timestamptz columns
Date: 2016-09-29 13:15:22
Message-ID: 5497.1475154922@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I wrote:
> You could try constructing a GIST or SPGIST index on the ranges
> tstzrange(s, e), where you'd have to do something to convert null
> endpoints to infinities, and then probing with WHERE rangeexpr @> now().

Or actually, it looks like tstzrange() already does the right thing:

regression=# select tstzrange(now(), null);
tstzrange
-----------------------------------
["2016-09-29 09:12:14.79429-04",)
(1 row)

regression=# select tstzrange(null, now());
tstzrange
------------------------------------
(,"2016-09-29 09:12:33.632327-04")
(1 row)

So this just reduces to WHERE tstzrange(s, e) @> now().

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message James Cloos 2016-09-29 15:48:02 Re: using possibly null timestamptz columns
Previous Message Tom Lane 2016-09-29 13:05:48 Re: using possibly null timestamptz columns