pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Gaetano Mendola <mendola@bigfoot.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Wrong plan sequential scan instead of an index one
Date: Fri, 30 Mar 2007 11:33:25 +0100
Message-ID: <460CE775.8080908@archonet.com> (raw)
In-Reply-To: <460CE359.8060208@bigfoot.com>
References: <460CD941.6080303@bigfoot.com>
	<460CDCDC.7020901@archonet.com>
	<460CE359.8060208@bigfoot.com>

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



view thread (15+ messages)  latest in thread

Message-ID: <460CE775.8080908@archonet.com>
Permalink:  ../460CE775.8080908@archonet.com/
Also on:    postgresql.org/message-id/460CE775.8080908@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, mendola@bigfoot.com
  Subject: Re: Wrong plan sequential scan instead of an index one
  In-Reply-To: <460CE775.8080908@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox