Re: Difference in query plan when using = or > in where clause - Mailing list pgsql-performance

From Heikki Linnakangas
Subject Re: Difference in query plan when using = or > in where clause
Date
Msg-id 46FBA46B.2080903@enterprisedb.com
Whole thread Raw
In response to Difference in query plan when using = or > in where clause  ("Radhika S" <radhika.sambamurti@gmail.com>)
List pgsql-performance
Radhika S wrote:
> I am curious as to why this occurs. Why does an = change the query plan so
> drastically?
>
> When my query is:
> Select count(*) from View_A WHERE tradedate = '20070801';
> The query plan is as below:
> ...
> But when my query is:
> Select count(*) from View_A WHERE tradedate BETWEEN '20070801' and
> '20070901';
> The query plan is:
> ...

In short, the planner estimates that "tradedate BETWEEN '20070801' and
'20070901'" matches more rows than "tradatedate = '20070801'"

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

pgsql-performance by date:

Previous
From: Csaba Nagy
Date:
Subject: Re: Searching for the cause of a bad plan
Next
From: Tom Lane
Date:
Subject: Re: Searching for the cause of a bad plan