agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: James Cloos <cloos@jhcloos.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: using possibly null timestamptz columns
Date: Thu, 29 Sep 2016 09:15:22 -0400
Message-ID: <5497.1475154922@sss.pgh.pa.us> (raw)
In-Reply-To: <5086.1475154348@sss.pgh.pa.us>
References: <m3a8eqx4rx.fsf@carbon.jhcloos.org>
	<5086.1475154348@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (4+ messages)  latest in thread

Message-ID: <5497.1475154922@sss.pgh.pa.us>
Permalink:  ../5497.1475154922@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5497.1475154922@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, cloos@jhcloos.com
  Subject: Re: using possibly null timestamptz columns
  In-Reply-To: <5497.1475154922@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox