Re: Wrong plan sequential scan instead of an index one - Mailing list pgsql-performance

From Richard Huxton
Subject Re: Wrong plan sequential scan instead of an index one
Date
Msg-id 460CE775.8080908@archonet.com
Whole thread Raw
In response to Re: Wrong plan sequential scan instead of an index one  (Gaetano Mendola <mendola@bigfoot.com>)
List 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

pgsql-performance by date:

Previous
From: Gaetano Mendola
Date:
Subject: Re: Wrong plan sequential scan instead of an index one
Next
From: ismo.tuononen@solenovo.fi
Date:
Subject: Re: Wrong plan sequential scan instead of an index one