Re: Select "todays" timestamps in an index friendly way

From: "Lutz Horn" <lutz(dot)horn(at)posteo(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Select "todays" timestamps in an index friendly way
Date: 2018-10-23 10:12:40
Message-ID: 20181023101239.GB21523@lutz-pc.ecm4u.intra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lutz Horn 2018-10-23 10:19:49 Re: Select "todays" timestamps in an index friendly way
Previous Message Thomas Kellerer 2018-10-23 10:11:55 Re: Select "todays" timestamps in an index friendly way