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