pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Rhaoni Chiu Pereira <rhaoni@sistemica.info>
Cc: Lista PostgreSQL <pgsql-admin@postgresql.org>
Subject: Re: How to force an Index ?
Date: Tue, 26 Aug 2003 14:45:58 -0500
Message-ID: <20030826194558.GA19181@wolff.to> (raw)
In-Reply-To: <1061925116.3f4bb0fc641b2@www.sistemica.info>
References: <1061925116.3f4bb0fc641b2@www.sistemica.info>

On Tue, Aug 26, 2003 at 16:11:56 -0300,
  Rhaoni Chiu Pereira <rhaoni@sistemica.info> wrote:
> Hi List,
> 
>      I'm looking for a way to force an Index to be used in a SQL query. In a 
> Oracle SQL query it would be like: 
> 
>     Select /*+ my_index*/ * from my_table where my_name="rhaoni";
> 
>    So it would use the index my_index to execute the query. How can I make this 
> in a PostgreSQL SQL query.

There isn't a way to force specific indexes to be used. You can raise the
cost of sequential scans so that index scans will almost always be used
if they are possible. Use: set enable_seqscan = false;

In general it is best to use this only to find out why an index scan isn't
being used and then potentially change some cost functions so that the
proper plan is chosen.



view thread (9+ messages)  latest in thread

Message-ID: <20030826194558.GA19181@wolff.to>
Permalink:  ../20030826194558.GA19181@wolff.to/
Also on:    postgresql.org/message-id/20030826194558.GA19181@wolff.to

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: bruno@wolff.to, rhaoni@sistemica.info
  Subject: Re: How to force an Index ?
  In-Reply-To: <20030826194558.GA19181@wolff.to>
  References: <1061925116.3f4bb0fc641b2@www.sistemica.info> <20030826194558.GA19181@wolff.to>

* 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