Re: only one index is using, why?

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: only one index is using, why?
Date: 2010-12-15 08:52:03
Message-ID: AANLkTikAWrH36myhdgYghVrtVf1h92iOp6hcd2rDZL+h@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, Dec 15, 2010 at 08:56, AI Rumman <rummandba(at)gmail(dot)com> wrote:
> My question is why "crmentity_setype_idx" index is being used only.
> "crmentity_deleted_idx" index is not using.
> Any idea please.

Because the planner determined that the cost of scanning *two* indexes
and combining the results is more expensive than scanning one index
and filtering the results afterwards.

Looks like your query could use a composite index on both columns:
(deleted, setype)
Or a partial index: (setype) WHERE deleted=0

Regards,
Marti

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Rauan Maemirov 2010-12-15 13:56:33 Problems with FTS
Previous Message AI Rumman 2010-12-15 06:56:32 only one index is using, why?