X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D6F2CD1B949; Fri, 5 Sep 2003 10:07:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 19136-03; Fri, 5 Sep 2003 07:07:16 -0300 (ADT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 7437CD1B8AE; Fri, 5 Sep 2003 07:07:13 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 19vDUp-0000Ch-0V; Fri, 05 Sep 2003 11:07:15 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 4FAF617326; Fri, 5 Sep 2003 11:07:14 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id A8DA116B91; Fri, 5 Sep 2003 11:07:13 +0100 (BST) From: Richard Huxton To: "Bjorn T Johansen" , pgsql-general@postgresql.org Subject: Re: [PERFORM] Seq scan of table? Date: Fri, 5 Sep 2003 11:07:12 +0100 User-Agent: KMail/1.5 Cc: pgsql-performance@postgresql.org References: <58940.193.212.14.12.1062742087.squirrel@www.havleik.no> <31414.193.212.14.12.1062751674.squirrel@www.havleik.no> In-Reply-To: <31414.193.212.14.12.1062751674.squirrel@www.havleik.no> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200309051107.12756.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/426 X-Sequence-Number: 48648 On Friday 05 September 2003 09:47, Bjorn T Johansen wrote: > I think I have found out why.. I have a where clause on a ID field but it > seems like I need to cast this integer to the same integer as the field is > defined in the table, else it will do a tablescan. > > Is this assumtion correct? And if it is, do I then need to change all my > sql's to cast the where clause where I just have a number (eg where field > = 1) to force the planner to use index scan instead of seq scan? PG's parser will assume an explicit number is an int4 - if you need an int8 etc you'll need to cast it, yes. You should find plenty of discussion of why in the archives, but the short reason is that PG's type structure is quite flexible which means it can't afford to make too many assumptions. -- Richard Huxton Archonet Ltd