Re: [SQL] Why is it not using an index?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] Why is it not using an index?
Date: 2002-03-15 18:18:43
Message-ID: 20020315101751.N51975-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql


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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cornelia Boenigk 2002-03-15 18:21:34 How to catch NOTIFY messages with PHP
Previous Message John Gray 2002-03-15 18:07:32 Re: Archives / News gateway

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry Tkach 2002-03-15 18:20:59 Btree index extension question
Previous Message Frederick Klauschen 2002-03-15 18:17:39 JDBC for J2ME