Re: Wrong plan sequential scan instead of an index one

From: Richard Huxton <dev(at)archonet(dot)com>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Wrong plan sequential scan instead of an index one
Date: 2007-03-30 10:33:25
Message-ID: 460CE775.8080908@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Gaetano Mendola wrote:
>
> Richard Huxton wrote:
>>
>> Now, why 19 rows from the subquery should produce such a large estimate
>> in the outer query I'm not sure. Any strange distribution of values on
>> pvcp?
>
> I don't know what do you mean for strange, this is the distribution:
>
> test=# select count(*) from t_oa_2_00_card;
> count
> - --------
> 877682
> (1 row)
>
> test=# select count(*), pvcp from t_oa_2_00_card group by pvcp;
> count | pvcp
> - -------+------
> (92 rows)
>
>
> I think that estimate is something like: 877682 / 92 * 19

So if you actually had 19 matches for '%pi%' it might be a sensible plan
then. I'm afraid I don't know of any way to improve PG's prediction on
how many matches you'll get for a substring pattern though.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message ismo.tuononen 2007-03-30 10:43:53 Re: Wrong plan sequential scan instead of an index one
Previous Message Gaetano Mendola 2007-03-30 10:15:53 Re: Wrong plan sequential scan instead of an index one