Re: select is not using index?

From: Corey Edwards <coreyed(at)linxtechnologies(dot)com>
To: Mark Harrison <mh(at)pixar(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: select is not using index?
Date: 2004-02-04 23:22:23
Message-ID: 1075936942.12400.18.camel@harvey
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Slavisa Garic 2004-02-05 00:42:32 Re: COPY from question
Previous Message Mark Harrison 2004-02-04 22:55:15 select is not using index?