From: Lutz Horn <lutz.horn@posteo.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: Select "todays" timestamps in an index friendly way
Date: Tue, 23 Oct 2018 12:12:40 +0200
Message-ID: <20181023101239.GB21523@lutz-pc.ecm4u.intra> (raw)
In-Reply-To: <CA+bJJbxdw7oy0osqT4Q2mBrSRJYsLfVmQyL3ZUsmML4iyX+PQw@mail.gmail.com>
References: <20181023093801.GA21523@lutz-pc.ecm4u.intra>
<CA+bJJbxdw7oy0osqT4Q2mBrSRJYsLfVmQyL3ZUsmML4iyX+PQw@mail.gmail.com>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: lutz.horn@posteo.de
Subject: Re: Select "todays" timestamps in an index friendly way
In-Reply-To: <20181023101239.GB21523@lutz-pc.ecm4u.intra>
References: <20181023093801.GA21523@lutz-pc.ecm4u.intra> <CA+bJJbxdw7oy0osqT4Q2mBrSRJYsLfVmQyL3ZUsmML4iyX+PQw@mail.gmail.com> <20181023101239.GB21523@lutz-pc.ecm4u.intra>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox