Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxJaV-0004Xe-37 for pgsql-performance@arkaria.postgresql.org; Mon, 21 Jan 2013 15:47:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TxJaU-0002E5-2Q for pgsql-performance@arkaria.postgresql.org; Mon, 21 Jan 2013 15:47:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxJaT-0002Dz-2O for pgsql-performance@postgresql.org; Mon, 21 Jan 2013 15:47:05 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TxJaO-0001zT-Mc for pgsql-performance@postgresql.org; Mon, 21 Jan 2013 15:47:03 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 34E1D28F1B; Mon, 21 Jan 2013 07:46:57 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 31D7C180D2; Mon, 21 Jan 2013 07:46:57 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 285FA1219D7; Mon, 21 Jan 2013 07:49:17 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-1.vmware.com Received: from zcs-prod-ext-mta-1.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-1.vmware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZLjnRITAggwo; Mon, 21 Jan 2013 07:49:17 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 00B5E1219D5; Mon, 21 Jan 2013 07:49:16 -0800 (PST) Received: from [192.168.1.90] (unknown [10.113.62.14]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Mon, 21 Jan 2013 07:49:16 -0800 (PST) Message-ID: <50FD62FD.2080802@vmware.com> Date: Mon, 21 Jan 2013 17:47:09 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 MIME-Version: 1.0 To: AJ Weber CC: pgsql-performance@postgresql.org Subject: Re: Analyze and default_statistics_target References: <50FD5EDE.8010002@comcast.net> In-Reply-To: <50FD5EDE.8010002@comcast.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 21.01.2013 17:29, AJ Weber wrote: > I was under the impression that the default_statistics_target was a > percentage of rows to analyze. Maybe this is not the case? Nope. > I ran an analyze during a "quiet point" last night and for a few of my > large tables, I didn't get what I consider a reasonable sampling of > rows. When running with "verbose" enabled, it appeared that a maximum of > 240000 rows were being analyzed, including on tables exceeding 4-8mm > rows. My default_statistics_target = 80. > > Shouldn't I be analyzing a larger percentage of these big tables? Analyze only needs a fairly small random sample of the rows in the table to get a picture of what the data looks like. Compare with e.g opinion polls; you only need to sample a few thousand people to get a result with reasonable error bound. That's for estimating the histogram. Estimating ndistinct is a different story, and it's well-known that the estimates of ndistinct are sometimes wildly wrong. > What is the unit-of-measure used for default_statistics_target? It's the number of entries stored in the histogram and most-common-values list in pg_statistics. See also http://www.postgresql.org/docs/devel/static/planner-stats.html: "The amount of information stored in pg_statistic by ANALYZE, in particular the maximum number of entries in the most_common_vals and histogram_bounds arrays for each column, can be set on a column-by-column basis using the ALTER TABLE SET STATISTICS command, or globally by setting the default_statistics_target configuration variable. The default limit is presently 100 entries." - Heikki -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance