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 C45EB538AC; Wed, 27 Apr 2005 14:17:19 -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 31589-06; Wed, 27 Apr 2005 17:17:09 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id EBFB653892; Wed, 27 Apr 2005 14:17:07 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DQq9Y-0001dt-00; Wed, 27 Apr 2005 13:16:48 -0400 To: "Dave Held" Cc: "pgsql-perform" , Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested? References: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184E1@asg002.asg.local> In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F9026184E1@asg002.asg.local> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Apr 2005 13:16:48 -0400 Message-ID: <87ekcw3zsv.fsf@stark.xeocode.com> Lines: 24 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/734 X-Sequence-Number: 12131 "Dave Held" writes: > > Actually, it's more to characterize how large of a sample > > we need. For example, if we sample 0.005 of disk pages, and > > get an estimate, and then sample another 0.005 of disk pages > > and get an estimate which is not even close to the first > > estimate, then we have an idea that this is a table which > > defies analysis based on small samples. > > I buy that. Better yet is to use the entire sample you've gathered of .01 and then perform analysis on that sample to see what the confidence interval is. Which is effectively the same as what you're proposing except looking at every possible partition. Unfortunately the reality according to the papers that were sent earlier is that you will always find the results disappointing. Until your sample is nearly the entire table your estimates for n_distinct will be extremely unreliable. -- greg