Skip site navigation (1) Skip section navigation (2)

Re: Difference in query plan when using = or > in where clause

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Radhika S <radhika(dot)sambamurti(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Difference in query plan when using = or > in where clause
Date: 2007-09-27 12:39:07
Message-ID: 46FBA46B.2080903@enterprisedb.com (view raw or flat)
Thread:
Lists: 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

In response to

pgsql-performance by date

Next:From: Tom LaneDate: 2007-09-27 14:40:25
Subject: Re: Searching for the cause of a bad plan
Previous:From: Csaba NagyDate: 2007-09-27 11:53:24
Subject: Re: Searching for the cause of a bad plan

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group