X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E7F47535AF for ; Fri, 22 Apr 2005 17:31:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57401-10 for ; Fri, 22 Apr 2005 20:30:59 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 7E74C5320A for ; Fri, 22 Apr 2005 17:30:58 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 7270293; Fri, 22 Apr 2005 13:32:57 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Marko Ristola Subject: Re: Bad n_distinct estimation; hacks suggested? Date: Fri, 22 Apr 2005 13:36:08 -0700 User-Agent: KMail/1.7.1 Cc: pgsql-perform References: <200504191209.05181.josh@agliodbs.com> <426944D0.6040706@kolumbus.fi> <200504221152.51736.josh@agliodbs.com> In-Reply-To: <200504221152.51736.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200504221336.08325.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/623 X-Sequence-Number: 12020 > > Solaris is unknown to me. Maybe the used random number generator there > > isn't good enough? > > Hmmm. Good point. Will have to test on Linux. Nope: Linux 2.4.20: test=# select tablename, attname, n_distinct from pg_stats where tablename = 'web_site_activity_fa'; tablename | attname | n_distinct ----------------------+---------------------+------------ web_site_activity_fa | session_id | 626127 test=# select count(distinct session_id) from web_site_activity_fa; count --------- 3174813 (1 row) ... I think the problem is in our heuristic sampling code. I'm not the first person to have this kind of a problem. Will be following up with tests ... -- --Josh Josh Berkus Aglio Database Solutions San Francisco