From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Radhika S <radhika.sambamurti@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Difference in query plan when using = or > in where clause
Date: Thu, 27 Sep 2007 13:39:07 +0100
Message-ID: <46FBA46B.2080903@enterprisedb.com> (raw)
In-Reply-To: <fe27bfd40709261100s1303c35bidd526354b57f62c6@mail.gmail.com>
References: <fe27bfd40709261100s1303c35bidd526354b57f62c6@mail.gmail.com>
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
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: heikki@enterprisedb.com, radhika.sambamurti@gmail.com
Subject: Re: Difference in query plan when using = or > in where clause
In-Reply-To: <46FBA46B.2080903@enterprisedb.com>
* 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