Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpaai-0003JC-0b for pgsql-sql@arkaria.postgresql.org; Thu, 29 Sep 2016 12:37:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bpaah-0007Bl-Jh for pgsql-sql@arkaria.postgresql.org; Thu, 29 Sep 2016 12:37:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bpaaf-00076Q-1x for pgsql-sql@postgresql.org; Thu, 29 Sep 2016 12:37:29 +0000 Received: from ore.jhcloos.com ([198.147.22.87]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bpaaW-0006Nm-Uj for pgsql-sql@postgresql.org; Thu, 29 Sep 2016 12:37:27 +0000 Received: by ore.jhcloos.com (Postfix, from userid 10) id B09A61E189; Thu, 29 Sep 2016 12:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jhcloos.com; s=ore14; t=1475152635; bh=DIlI1aGzV3GkB8a/XVkLtL0D60KIDOs33XFRLakf3YI=; h=From:To:Subject:Date:From; b=CmU1h6W1VAsKNoQiwumsqeRtY2rYn8H5+dJgoOyFJ3rlVvpIIPihGZghxhyF+KNy6 D/vbdSyY8Rj4jyjNWif+qw7fJh3Jhhnqj3ue0MLL0o6akjHwOVhbJMCrss0LrNuCMe vxMZ0tBMhqS+kOaS5lWv8Yvk8MsU9OPfvUAIW7nE= Received: by carbon.jhcloos.org (Postfix, from userid 500) id 24F88107AC443; Thu, 29 Sep 2016 12:35:30 +0000 (UTC) From: James Cloos To: pgsql-sql@postgresql.org Subject: using possibly null timestamptz columns User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAACVBMVEX///8ZGXBQKKnCrDQ3 AAAAJElEQVQImWNgQAAXzwQg4SKASgAlXIEEiwsSIYBEcLaAtMEAADJnB+kKcKioAAAAAElFTkSu QmCC Copyright: Copyright 2016 James Cloos OpenPGP: 0x997A9F17ED7DAEA6; url=https://jhcloos.com/public_key/0x997A9F17ED7DAEA6.asc OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6 Date: Thu, 29 Sep 2016 08:35:30 -0400 Message-ID: Lines: 11 MIME-Version: 1.0 Content-Type: text/plain X-Hashcash: 1:28:160929:pgsql-sql@postgresql.org::39H/3Kaq21fEQ6zH:000000000000000000000000000000000000brVYg X-Pg-Spam-Score: -5.0 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 OpenPGP: 0x997A9F17ED7DAEA6 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql