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 B2B0753F95; Tue, 3 May 2005 10:08: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 27718-05; Tue, 3 May 2005 13:08:16 +0000 (GMT) Received: from mail.logix-tt.com (wallaby.dingens.org [212.75.36.180]) by svr1.postgresql.org (Postfix) with ESMTP id 511BC53F93; Tue, 3 May 2005 10:08:15 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (pD95DD5E9.dip0.t-ipconnect.de [217.93.213.233]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id DD1F3A861E; Tue, 3 May 2005 15:08:18 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with ESMTP id 9EBC3AB2D2; Tue, 3 May 2005 15:06:24 +0200 (CEST) Message-ID: <4277774F.7040205@logix-tt.com> Date: Tue, 03 May 2005 15:06:23 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-perform Cc: pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Bad n_distinct estimation; hacks suggested? References: <200504191209.05181.josh@agliodbs.com> <1114580284.426f253cc0087@webmail.telus.net> <426F9703.4010108@dunslane.net> <200504270825.17550.josh@agliodbs.com> In-Reply-To: <200504270825.17550.josh@agliodbs.com> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/202 X-Sequence-Number: 67078 Hi, Josh, Josh Berkus wrote: > Yes, actually. We need 3 different estimation methods: > 1 for tables where we can sample a large % of pages (say, >= 0.1) > 1 for tables where we sample a small % of pages but are "easily estimated" > 1 for tables which are not easily estimated by we can't afford to sample a > large % of pages. > > If we're doing sampling-based estimation, I really don't want people to lose > sight of the fact that page-based random sampling is much less expensive than > row-based random sampling. We should really be focusing on methods which > are page-based. Would it make sense to have a sample method that scans indices? I think that, at least for tree based indices (btree, gist), rather good estimates could be derived. And the presence of a unique index should lead to 100% distinct values estimation without any scan at all. Markus