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 10:48:12 +0100
Message-ID: <460CDCDC.7020901@archonet.com> (raw)
In-Reply-To: <460CD941.6080303@bigfoot.com>
References: <460CD941.6080303@bigfoot.com>

Gaetano Mendola wrote:
> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
> 
> Hi all, take a look at those plans:
> 
> 
> test=# explain analyze SELECT COUNT(id) FROM t_oa_2_00_card WHERE
> pvcp in (select id from l_pvcp where value ilike '%pi%');

> ->  Hash IN Join  (cost=2.22..153835.49 rows=177404 width=8) (actual
> time=2.908..4001.814 rows=7801 loops=1) Hash Cond: ("outer".pvcp =
> "inner".id)

> Isn't too much choose a sequential scan due to 19 estimated rows when
> with 4 estimated does a correct index scan ?

I don't think it's the matches on l_pvcp that's the problem, it's the 
fact that it thinks its getting 177404 rows matching the IN.

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?

-- 
   Richard Huxton
   Archonet Ltd



view thread (15+ messages)  latest in thread

Message-ID: <460CDCDC.7020901@archonet.com>
Permalink:  ../460CDCDC.7020901@archonet.com/
Also on:    postgresql.org/message-id/460CDCDC.7020901@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: <460CDCDC.7020901@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