Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 671B2632A38 for ; Thu, 2 Apr 2009 12:00:47 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 95951-08 for ; Thu, 2 Apr 2009 12:00:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 8DEA4632F9B for ; Thu, 2 Apr 2009 12:00:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n32F0gPQ022530; Thu, 2 Apr 2009 11:00:43 -0400 (EDT) To: Alvaro Herrera cc: James Kitambara , Srikanth , pgsql-sql@postgresql.org Subject: Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps In-reply-to: <20090402135404.GD3163@alvh.no-ip.org> References: <19947.64230.qm@web94606.mail.in2.yahoo.com> <49BFBC61.9020006@archonet.com> <849335.93192.qm@web27903.mail.ukl.yahoo.com> <20090402135404.GD3163@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Thu, 02 Apr 2009 09:54:04 -0400" Date: Thu, 02 Apr 2009 11:00:42 -0400 Message-ID: <22529.1238684442@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/13 X-Sequence-Number: 32359 Alvaro Herrera writes: > Another way to phrase the WHERE clause is with the OVERLAPS operator, > something like this: > WHERE (start_ts, end_ts) OVERLAPS ('2008-12-07 07:59:59', '2008-12-07 08:59:59') > What I'm not so sure about is how optimizable this construct is. Not at all :-( --- or at least, our code doesn't do anything with it currrently; I shouldn't claim that it's impossible to optimize. regards, tom lane