Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5E8BDB5DBDD for ; Fri, 10 Jun 2011 16:58:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 07471-10 for ; Fri, 10 Jun 2011 19:58:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-4.01.com (smtp-4.01.com [38.102.63.183]) by mail.postgresql.org (Postfix) with ESMTP id 275D7B5DBDB for ; Fri, 10 Jun 2011 16:58:21 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-4.01.com (Postfix) with ESMTP id 0D2473BC2F7 for ; Fri, 10 Jun 2011 14:58:21 -0500 (CDT) Received: from smtp-4.01.com ([127.0.0.1]) by localhost (smtp-4.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xFRK-iNXnVVk for ; Fri, 10 Jun 2011 14:58:20 -0500 (CDT) Received: by smtp-4.01.com (Postfix, from userid 99) id E544D3BC2F0; Fri, 10 Jun 2011 14:58:20 -0500 (CDT) Received: from Sidney-Stratton.local (70-36-143-92.dsl.dynamic.sonic.net [70.36.143.92]) by smtp-4.01.com (Postfix) with ESMTPSA id A38C43BC210 for ; Fri, 10 Jun 2011 14:58:20 -0500 (CDT) Message-ID: <4DF2775B.7070501@agliodbs.com> Date: Fri, 10 Jun 2011 12:58:19 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: change sample size for statistics References: In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/126 X-Sequence-Number: 44059 On 6/10/11 5:15 AM, Willy-Bas Loos wrote: > Hi, > > is there a way to change the sample size for statistics (that analyze > gathers)? > It is said to be 10%. i would like to raise that, because we are getting bas > estimations for n_distinct. It's not 10%. We use a fixed sample size, which is configurable on the system, table, or column basis. Some reading (read all these pages to understand what you're doing): http://www.postgresql.org/docs/9.0/static/planner-stats.html http://www.postgresql.org/docs/9.0/static/runtime-config-query.html#RUNTIME-CONFIG-QUERY-OTHER http://www.postgresql.org/docs/9.0/static/planner-stats-details.html http://www.postgresql.org/docs/9.0/static/sql-altertable.html (scroll down to "set storage" on that last page) -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com