Re: Using index name in select Query - Mailing list pgsql-novice

From Luca Ferrari
Subject Re: Using index name in select Query
Date
Msg-id CAKoxK+6DD82qYGoc8UsbJ-S-=bsNSj7rMqAg305vjc1sGO65+g@mail.gmail.com
Whole thread Raw
In response to Re: Using index name in select Query  ("naman.iitb" <naman.bbps@gmail.com>)
List pgsql-novice
On Sat, Oct 19, 2013 at 4:28 PM, naman.iitb <naman.bbps@gmail.com> wrote:

> Now my requirement is if i know the index name i.e. index_abcd then is there
> a way by which i can use it in the select query so that i can be sure that
> optimizer will pick the index specified(i.e index_abcd) and no other.
>

What you want is called "query hints" and PostgreSQL, as pointed out
by others, do not support it by policy. The idea is that the planner
knows better than you what to do with your query. What you believe is
the better index today could be the bad index tomorrow, or even a few
seconds after you just told your boss how smart you have  been
designing such index, and that is strictly tied to the workload of
your cluster.
The only way to force PostgreSQL using your own index is to disable
all other access methods (e.g., enabled_seqscan = off) and to make all
other indexes not available (via catalogs). But this will impact all
your cluster.

Any chance this is an homework?

Luca


pgsql-novice by date:

Previous
From: David Johnston
Date:
Subject: Re: Using index name in select Query
Next
From: James David Smith
Date:
Subject: COUNT and GROUP BY performing strangely