Re: using possibly null timestamptz columns - Mailing list pgsql-sql

From Tom Lane
Subject Re: using possibly null timestamptz columns
Date
Msg-id 5497.1475154922@sss.pgh.pa.us
Whole thread Raw
In response to Re: using possibly null timestamptz columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: using possibly null timestamptz columns
List 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



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: using possibly null timestamptz columns
Next
From: James Cloos
Date:
Subject: Re: using possibly null timestamptz columns