Re: select is not using index? - Mailing list pgsql-performance

From Corey Edwards
Subject Re: select is not using index?
Date
Msg-id 1075936942.12400.18.camel@harvey
Whole thread Raw
In response to select is not using index?  (Mark Harrison <mh@pixar.com>)
List pgsql-performance
On Wed, 2004-02-04 at 14:55, Mark Harrison wrote:
> testdb=# \d bigtable
>       Table "public.bigtable"
>   Column  |  Type   | Modifiers
> ---------+---------+-----------
>   id      | bigint  | not null
>   typeid  | integer | not null
>   reposid | integer | not null
> Indexes: bigtable_id_key unique btree (id)

> testdb=# explain select * from bigtable where id = 123;

Your column is a bigint but 123 defaults to type int. Indexes aren't
used when there's a type mismatch. Use an explicit cast or quote it:

  select * from bigtable where id = 123::bigint;

Or

  select * from bigtable where id = '123';

Corey



pgsql-performance by date:

Previous
From: Mark Harrison
Date:
Subject: select is not using index?
Next
From: Orion Henry
Date:
Subject: 7.3 vs 7.4 performance