On Fri, Nov 12, 2010 at 11:12 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> if I remember well, you can set a number of group by ALTER TABLE ALTER
> COLUMN SET n_distinct = ..
>
> maybe you use it.
I'm not sure where the number 40,000 is coming from either, but I
think Pavel's suggestion is a good one. If you're grouping on a
column with N distinct values, then it stands to reason there will be
N groups, and the planner is known to estimate n_distinct on large
tables, even with very high statistics targets, which is why 9.0
allows a manual override.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company