any way to make query use index?

From: "Chris Hoover" <revoohc(at)gmail(dot)com>
To: "pgsql-admin(at)postgresql(dot)org Admin" <pgsql-admin(at)postgresql(dot)org>
Subject: any way to make query use index?
Date: 2007-11-15 15:14:41
Message-ID: 1d219a6f0711150714j6f192548xe4c134a25e5b57b2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I am working through our application looking for ways to eliminate seq
scans in our database. I am looking for some help with this query.

SELECT rev_desc FROM rev_code_desc WHERE rev_code = lpad('0300', 4, '0')

Is there anyway to make postgres use an index on this query?

Here is the table definition:
CREATE TABLE rev_code_desc
(
rev_code character(4) NOT NULL,
rev_desc text,
user_id character varying(12),
live_rec boolean DEFAULT true,
CONSTRAINT rev_code_desc_pkey PRIMARY KEY (rev_code)
)

Right now, I can't seem to get it to use an index for this type of
query. Of course, in our application it is SELECT rev_desc FROM
rev_code_desc WHERE rev_code = lpad(<program variable>, 4, '0').

Thanks for any help,

Chris

PG 8.1.3

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message König, Monika 2007-11-15 15:29:51 trigger ddl actions in a table
Previous Message Richard Broersma Jr 2007-11-15 14:50:37 "global/pg_control": Permission denied