On Fri, Nov 12, 2010 at 11:12 AM, Pavel Stehule <pavel.stehule@xxxxxxxxx> 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 -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance