X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2BB1653635; Tue, 3 May 2005 18:42:36 -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 05399-01; Tue, 3 May 2005 21:42:34 +0000 (GMT) Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by svr1.postgresql.org (Postfix) with ESMTP id 691F453601; Tue, 3 May 2005 18:42:33 -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 7316960; Tue, 03 May 2005 14:44:35 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Mischa Sandberg Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? Date: Tue, 3 May 2005 14:43:44 -0700 User-Agent: KMail/1.7.1 Cc: Markus Schaber , pgsql-perform , pgsql-hackers@postgresql.org References: <200504191209.05181.josh@agliodbs.com> <4277774F.7040205@logix-tt.com> <1115155990.4277ee16aba34@webmail.telus.net> In-Reply-To: <1115155990.4277ee16aba34@webmail.telus.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505031443.44859.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/256 X-Sequence-Number: 67132 Mischa, > Okay, although given the track record of page-based sampling for > n-distinct, it's a bit like looking for your keys under the streetlight, > rather than in the alley where you dropped them :-) Bad analogy, but funny. The issue with page-based vs. pure random sampling is that to do, for example, 10% of rows purely randomly would actually mean loading 50% of pages. With 20% of rows, you might as well scan the whole table. Unless, of course, we use indexes for sampling, which seems like a *really good* idea to me .... -- --Josh Josh Berkus Aglio Database Solutions San Francisco