Re: index selection by query planner

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rohit Gaddi <rohitgaddi(at)yahoo(dot)co(dot)in>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: index selection by query planner
Date: 2005-06-21 15:38:36
Message-ID: 11691.1119368316@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Rohit Gaddi <rohitgaddi(at)yahoo(dot)co(dot)in> writes:
> I have a table with two indices on the same column, one of which is a partial index. I would like the query planner to use the partial index whenever the query condition lies in the range of the partial index as it would yield better performance. Is there any way to enforce the ordering for the indices? How does the query planner decide which index to use when a particular query is fired? 'Explain Analyze' showed the total index being used in a situation that could be fulfiled by the partial index.

When you're asking this sort of question you should actually *show* the
EXPLAIN ANALYZE results. I would also suggest showing the comparison
to the other plan, which you can get in a nondestructive way like this:

EXPLAIN ANALYZE .... ;
-- plan using total index here

BEGIN;
DROP INDEX total_index;
EXPLAIN ANALYZE .... ;
-- plan using partial index here, we hope
ROLLBACK;

Also, this is really on-topic for pgsql-performance, not either of the
two lists you have chosen.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2005-06-21 16:17:56 Re: Escape handling in strings
Previous Message Tom Lane 2005-06-21 15:34:23 Re: Escape handling in strings

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2005-06-21 15:44:20 Re: [PATCHES] default database creation with initdb
Previous Message Tom Lane 2005-06-21 15:34:23 Re: Escape handling in strings