X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id B5D839FA220 for ; Fri, 2 Jun 2006 16:24:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 09967-08 for ; Fri, 2 Jun 2006 16:24:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by postgresql.org (Postfix) with ESMTP id 8D4FA9FA0E5 for ; Fri, 2 Jun 2006 16:24:03 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [64.81.245.111] (account josh@agliodbs.com HELO [192.168.1.27]) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 9515220; Fri, 02 Jun 2006 12:27:13 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Greg Stark Subject: Re: More thoughts about planner's cost estimates Date: Fri, 2 Jun 2006 12:23:34 -0700 User-Agent: KMail/1.8 Cc: David Fetter , Tom Lane , pgsql-hackers@postgresql.org References: <14821.1149104747@sss.pgh.pa.us> <20060602010412.GI10906@fetter.org> <87ac8vfptu.fsf@stark.xeocode.com> In-Reply-To: <87ac8vfptu.fsf@stark.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606021223.35168.josh@agliodbs.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/77 X-Sequence-Number: 84310 Greg, > Using a variety of synthetic and real-world data sets, we show that > distinct sampling gives estimates for distinct values queries that > are within 0%-10%, whereas previous methods were typically 50%-250% off, > across the spectrum of data sets and queries studied. Aha. It's a question of the level of error permissable. For our estimates, being 100% off is actually OK. That's why I was looking at 5% block sampling; it stays within the range of +/- 50% n-distinct in 95% of cases. > Doing a bit of basic searching around I think the tool we're looking for > here is called a "chi-squared test for independence". Augh. I wrote a program (in Pascal) to do this back in 1988. Now I can't remember the math. For a two-column test it's relatively computation-light, though, as I recall ... but I don't remember standard chi square works with a random sample. -- --Josh Josh Berkus PostgreSQL @ Sun San Francisco