Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEtgB-0005Ya-TM for pgsql-general@arkaria.postgresql.org; Tue, 23 Oct 2018 10:12:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEtgA-0001ka-9I for pgsql-general@arkaria.postgresql.org; Tue, 23 Oct 2018 10:12:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEtg9-0001kN-SU for pgsql-general@lists.postgresql.org; Tue, 23 Oct 2018 10:12:50 +0000 Received: from mout02.posteo.de ([185.67.36.66]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEtg6-0003vh-SN for pgsql-general@lists.postgresql.org; Tue, 23 Oct 2018 10:12:48 +0000 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id A7EA52400E6 for ; Tue, 23 Oct 2018 12:12:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1540289562; bh=h15AcJo8D+qK0dUM4zcVTHV+VYjp/eUY31ZqzozUdjo=; h=From:Date:To:Subject:From; b=ImY2B9aEYUXN4Ds7lnyw/t0GmEw+xK6Bsz5PEGa4riPYFu4fWynZ3xxlXxmbe85bC BO7TLmjhZx8S1D3Jx6HZhKpcFNE3fFyEdx6a+PFGG7huj9eaDa9mLoDeYaiMuWowWv TDTdRHQokXPJ7uoDUwk87tlebrAXcTInFCtHeynEFvBjCrz73PjRNT2sWsxi9j/QSX BUfGXdkiSBpzoB/39ap1qiFmWZH9ntwxUh5+LvuHiifL6pfmkYW3w6n00Ld4+rrs4r tYjakClBmHxvWmGXud2Fef5+Sd+FT+TIBm9Bs7sQkNWikYcaEf4+Z4e9zaif6iZCvV +802VF8838SwA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 42fTj515n4z9rxH for ; Tue, 23 Oct 2018 12:12:40 +0200 (CEST) Received: by posteo.de (sSMTP sendmail emulation); Tue, 23 Oct 2018 12:12:40 +0200 From: "Lutz Horn" Date: Tue, 23 Oct 2018 12:12:40 +0200 To: pgsql-general@lists.postgresql.org Subject: Re: Select "todays" timestamps in an index friendly way Message-ID: <20181023101239.GB21523@lutz-pc.ecm4u.intra> References: <20181023093801.GA21523@lutz-pc.ecm4u.intra> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Francisco, On Tue, Oct 23, 2018 at 12:05:17PM +0200, Francisco Olarte wrote: > 1st remark. Do NOT use closed interval for timestamps. Always use > half-open or you'll run into problems Good point, thanks. > where ts >= date_trunc('day',now()) > and ts < date_trunc('day',now()+'1 day') as tomorrow; > > IIRC this should use the index And it does! Thanks! Lutz