using possibly null timestamptz columns

From: James Cloos <cloos(at)jhcloos(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: using possibly null timestamptz columns
Date: 2016-09-29 12:35:30
Message-ID: m3a8eqx4rx.fsf@carbon.jhcloos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Given a table with a pair of timestamptz columns (lets call them s and e)
which are typically null, is there a better way to write this where clause
snippet:

where ( s is null or s <= now() ) and ( e is null or e >= now() )

In particular I hope to ensure efficient indexes.

-JimC
--
James Cloos <cloos(at)jhcloos(dot)com> OpenPGP: 0x997A9F17ED7DAEA6

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2016-09-29 13:05:48 Re: using possibly null timestamptz columns
Previous Message Michael Moore 2016-09-26 22:05:02 Re: cvs text to quoted cvs text