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 893FE537EA; Sat, 23 Apr 2005 21:33:18 -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 34686-07; Sun, 24 Apr 2005 00:33:13 +0000 (GMT) Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) by svr1.postgresql.org (Postfix) with ESMTP id 5A1B5537E2; Sat, 23 Apr 2005 21:33:12 -0300 (ADT) Received: from dunslane.net (localhost.localdomain [127.0.0.1]) (authenticated (0 bits)) by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id j3NNiSM19099; Sat, 23 Apr 2005 18:44:28 -0500 Received: from 24.211.165.134 (SquirrelMail authenticated user andrew@dunslane.net) by www.dunslane.net with HTTP; Sat, 23 Apr 2005 18:44:28 -0500 (CDT) Message-ID: <1963.24.211.165.134.1114299868.squirrel@www.dunslane.net> Date: Sat, 23 Apr 2005 18:44:28 -0500 (CDT) Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested? From: "Andrew Dunstan" To: In-Reply-To: <200504231639.11897.josh@agliodbs.com> References: <200504231639.11897.josh@agliodbs.com> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: , , , X-Mailer: SquirrelMail (version 1.2.5) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200504/659 X-Sequence-Number: 12056 Josh Berkus said: > > > Well, unusual distributions are certainly tough. But I think the > problem exists even for relatively well-distributed populations. > Part of it is, I believe, the formula we are using: > > n*d / (n - f1 + f1*n/N) > [snip] > > This is so broken, in fact, that I'm wondering if we've read the paper > right? I've perused the paper on almaden, and the DUJ1 formula > appears considerably more complex than the formula we're using. > > Can someone whose math is more recent than calculus in 1989 take a look > at that paper, and look at the formula toward the bottom of page 10, > and see if we are correctly interpreting it? I'm particularly > confused as to what "q" and "d-sub-n" represent. Thanks! > Math not too recent ... I quickly read the paper and independently came up with the same formula you say above we are applying. The formula is on the page that is numbered 6, although it's the tenth page in the PDF. q = n/N = ratio of sample size to population size d_sub_n = d = number of distinct classes in sample cheers andrew