Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-performance by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group