How to force the parser to use index scan instead of sequential scan

From: "ck" <ck(dot)karthic(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to force the parser to use index scan instead of sequential scan
Date: 2006-10-07 05:32:16
Message-ID: 1160199136.689868.167010@c28g2000cwb.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am using PostgreSQL 7.3.2. I have a large table in a
database , its primary key field is int8.
Almost all of my queries are written relaing to that field. That field
is B-Tree indexed. When i check the query plan i found that all the
queries are using sequential scan and index was not used. So my queries
are likely to be slow. But when i tried to convert the values given to
that field to int8 in a where condition then the parser is using the
index scan, Eg
select * from h057 where h057001 = 1142::int8
the above query uses index scan
select * from h057 where h057001 = 1142
the above query uses sequential scan.
Since there are large number of queries written and being used in the
production it is impossible to change all the queries. Please help me
by giving a suggestion to improve my query performance. I mean any
configuration level changes that helps to force the parser to use index
scan instead of sequential scan in the above case.
Thanks in advance.

ck

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2006-10-07 07:01:58 Re: ISO week dates
Previous Message Talha Khan 2006-10-07 01:44:15 Re: shared_buffer setting