pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Corey Edwards <coreyed@linxtechnologies.com>
To: Mark Harrison <mh@pixar.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: select is not using index?
Date: Wed, 04 Feb 2004 15:22:23 -0800
Message-ID: <1075936942.12400.18.camel@harvey> (raw)
In-Reply-To: <40217853.20309@pixar.com>
References: <40217853.20309@pixar.com>

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





view thread (3+ messages)  latest in thread

Message-ID: <1075936942.12400.18.camel@harvey>
Permalink:  ../1075936942.12400.18.camel@harvey/
Also on:    postgresql.org/message-id/1075936942.12400.18.camel@harvey

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: coreyed@linxtechnologies.com, mh@pixar.com
  Subject: Re: select is not using index?
  In-Reply-To: <1075936942.12400.18.camel@harvey>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox