Re: greater than vs between in where clause

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Yambu <hyambu(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: greater than vs between in where clause
Date: 2020-11-05 14:58:11
Message-ID: 5e49b484-632b-bd78-9459-88ec1ce20736@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/5/20 6:49 AM, Yambu wrote:
> May i know if there is a difference in speed between 1 ,2 and 3 below ,
> if column start_date is indexed
>
> 1.  select * from table_1 where start_date > '1 Oct 2020'
> 2. select   * from table_1 where start_date between '1 Oct 2020' and now()
> 3. select * from table_1 where start_date between '1 Oct 2020' and '5
> Nov 2020 23:59:59'

Run EXPLAIN ANALYZE(https://www.postgresql.org/docs/13/sql-explain.html)
on each and let us know.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Philip Semanchuk 2020-11-05 15:05:32 Re: precautions/prerequisites to take for specific table
Previous Message Yambu 2020-11-05 14:49:21 greater than vs between in where clause