Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 97C9F9FA440 for ; Thu, 27 Sep 2007 09:40:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 25942-03 for ; Thu, 27 Sep 2007 09:40:00 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id BFEE19F9E21 for ; Thu, 27 Sep 2007 09:40:00 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id f5so1766894nfh for ; Thu, 27 Sep 2007 05:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=ILr0wCQBGugkYnzM9Fu1r2JGolEB2vfrY6GXPRxa/D8=; b=JZ741sWn32GV+xl0keGR6Z9qGuIE9NBojTf6FUrEA3PCFe2AnZHmBdut86rOKtQo+kyPJ71ym8FemtjQzs9y41RzJUeHVAm9TNfJypTcu8r5iCFU3gqAFVwqsVSumUMg8gSXurhuuIonbgwxlS4JnfJ+2mtcZ++oCjdCj7w3wqM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=Ie3a7EtY2HsBF/Xx2Q4Qui1g8EKRQWBhbxN+Ixm2juml34zWEFTFxjNWTui3MwROvcAkr+b1A4KvXlEJZsHQKMQVP5FffdiVD45ckTTmoDmIH+tVYUOUTnnd4WQrakCKnyjSosmd+REt+ezXSPJwpy9Vsf1t4hTft2ZA9gBlgII= Received: by 10.78.137.7 with SMTP id k7mr1706152hud.1190896798407; Thu, 27 Sep 2007 05:39:58 -0700 (PDT) Received: from ?172.24.32.198? ( [62.232.55.118]) by mx.google.com with ESMTPS id 37sm1235295hub.2007.09.27.05.39.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Sep 2007 05:39:56 -0700 (PDT) Message-ID: <46FBA46B.2080903@enterprisedb.com> Date: Thu, 27 Sep 2007 13:39:07 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: Radhika S CC: pgsql-performance@postgresql.org Subject: Re: Difference in query plan when using = or > in where clause References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/455 X-Sequence-Number: 27000 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