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 460CDCDC.7020901@archonet.com
Whole thread Raw
In response to Wrong plan sequential scan instead of an index one  (Gaetano Mendola <mendola@bigfoot.com>)
Responses Re: Wrong plan sequential scan instead of an index one
List pgsql-performance
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

pgsql-performance by date:

Previous
From: "Claus Guttesen"
Date:
Subject: Re: Wrong plan sequential scan instead of an index one
Next
From: Gaetano Mendola
Date:
Subject: Re: Wrong plan sequential scan instead of an index one