Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id ABCB0476470; Fri, 15 Mar 2002 13:18:43 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 1DE50D5F7; Fri, 15 Mar 2002 10:18:43 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 139735BFE; Fri, 15 Mar 2002 10:18:43 -0800 (PST) Date: Fri, 15 Mar 2002 10:18:43 -0800 (PST) From: Stephan Szabo To: Dmitry Tkach Cc: , Subject: Re: [SQL] Why is it not using an index? In-Reply-To: <3C924680.4090806@openratings.com> Message-ID: <20020315101751.N51975-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200203/835 X-Sequence-Number: 22207 On Fri, 15 Mar 2002, Dmitry Tkach wrote: > This must be really simple, but I just can't get it :-( > I have a table (a) with a single column (x): > > Table "a" > Attribute | Type | Modifier > -----------+----------+---------- > x | smallint | > Index: a_idx > > > Index "a_idx" > Attribute | Type > -----------+---------- > x | smallint > btree > > The table has 10000000 rows.... > > Now, how come, when I do: > > explain select * from a where x=3; You'll need to cast the 3 into smallint explicitly, either 3::smallint or CAST(3 as smallint) should work.