Discussion:
How to force an Index ?
(too old to reply)
Rhaoni Chiu Pereira
2003-08-26 19:11:56 UTC
Permalink
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.

Atenciosamente,

Rhaoni Chiu Pereira
Sistêmica Computadores

Visite-nos na Web: http://sistemica.info
Fone/Fax : +55 51 3328 1122






---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
Bruno Wolff III
2003-08-26 19:45:58 UTC
Permalink
On Tue, Aug 26, 2003 at 16:11:56 -0300,
Post by Rhaoni Chiu Pereira
Hi List,
I'm looking for a way to force an Index to be used in a SQL query. In a
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.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ***@postgresql.org)
Loading...