Re: Why does the query planner use two full indexes, when a dedicated partial index exists?

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Richard Neill <rn214(at)richardneill(dot)org>
Cc: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Why does the query planner use two full indexes, when a dedicated partial index exists?
Date: 2012-12-20 05:12:14
Message-ID: CAMkU=1wYVjf63j+4ttZrVMmYfst7Q7ngez5e6X4s+keYbpcwdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wednesday, December 19, 2012, Richard Neill wrote:

> Thanks for your help,
>
> On 20/12/12 00:08, Sergey Konoplev wrote:
>
>> On Wed, Dec 19, 2012 at 3:49 PM, Richard Neill <rn214(at)richardneill(dot)org>
>> wrote:
>>
>>> * The reindex solution doesn't work. I just tried it, and the query
>>> planner
>>> is still using the wrong indexes.
>>>
>>

It switched to a better one of the wrong indices, though, and got several
times faster.

How did it get so bloated in the first place? Is the table being updated
so rapidly that the statistics might be wrong even immediately after
analyze finishes?

In any case, I can't get it to prefer the full index in 9.1.6 at all. The
partial index wins hands down unless the table is physically clustered by
the parcel_id_code column. In which that case, the partial index wins by
only a little bit.

This is what I did for the table:

create table tbl_tracker as select case when random()<0.001 then 2 else
case when random()< 0.00003 then NULL else 1 end end as exit_state,
(random()*99999)::int as parcel_id_code from generate_series(1,5000000) ;

Cheers,

Jeff

>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Richard Neill 2012-12-20 05:51:57 Re: Why does the query planner use two full indexes, when a dedicated partial index exists?
Previous Message Tom Lane 2012-12-20 03:06:30 Re: Why does the query planner use two full indexes, when a dedicated partial index exists?