Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0F38F9FB2ED for ; Mon, 21 May 2007 17:19:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45941-05 for ; Mon, 21 May 2007 17:19:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.250]) by postgresql.org (Postfix) with ESMTP id 60B589FB285 for ; Mon, 21 May 2007 17:19:03 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id d17so408435and for ; Mon, 21 May 2007 13:19:02 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=m9RBy+92T9jbi10JIQ6YvUpw0n9TOfNb4fmbQ40ux5+jeiLXf18gjLSPzfA6MaGkzeQvfQLpoja0pWxS1rkW43sm/GlxcdPoO5xo7A596X1JUkU5qrL/ZYT2jSXol5YwQXeygTdCia+SJ5B+lfMgnf8SU8xMl25IpjAKbbsh8XY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=oxMxLEE0pa1n+BAd721STBWB2dLmspiMDK3kMxjG0+hqjyUzEwXVX7ukn2mSkMuSbHGLpL+0ep0gXr2JWL8ROxMPQZSuoow/Er8hF8ETJTV0jUNSnw2hqys8AHrdM593P68d8rng69U0fXTkukwn7jGkgyTWhAas6nBqQ+FPpos= Received: by 10.100.94.3 with SMTP id r3mr3273515anb.1179778742196; Mon, 21 May 2007 13:19:02 -0700 (PDT) Received: by 10.100.143.13 with HTTP; Mon, 21 May 2007 13:19:02 -0700 (PDT) Message-ID: Date: Mon, 21 May 2007 13:19:02 -0700 From: "Y Sidhu" To: "Jim C. Nasby" Subject: Re: pg_stats how-to? Cc: pgsql-performance@postgresql.org In-Reply-To: <20070521172405.GF62346@nasby.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070514190748.GY69517@nasby.net> <20070514170959.a951eefc.wmoran@collaborativefusion.com> <1623.1179188449@sss.pgh.pa.us> <20070515233855.GC20707@nasby.net> <20070521172405.GF62346@nasby.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/399 X-Sequence-Number: 24789 Thanks again! I'll make the change and get those numbers. Yudhvir On 5/21/07, Jim C. Nasby wrote: > On Fri, May 18, 2007 at 04:26:05PM -0700, Y Sidhu wrote: > > >To answer your original question, a way to take a look at how bloated > > >your tables are would be to ANALYZE, divide reltuples by relpages from > > >pg_class (gives how many rows per page you have) and compare that to 8k > > >/ average row size. The average row size for table rows would be the sum > > >of avg_width from pg_stats for the table + 24 bytes overhead. For > > >indexes, it would be the sum of avg_width for all fields in the index > > >plus some overhead (8 bytes, I think). > > > > > >An even simpler alternative would be to install contrib/pgstattuple and > > >use the pgstattuple function, though IIRC that does read the entire > > >relation from disk. > > >-- > > >Jim Nasby decibel@decibel.org > > >EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) > > > > > > > Here are my results: > > > > a. SELECT sum(reltuples)/sum(relpages) as rows_per_page FROM pg_class; > > > > I get 66 > > > > b. SELECT (8000/(sum(avg_width)+24)) as table_stat FROM pg_stats; > > > > I get 1 > > And those results will be completely meaningless because they're > covering the entire database (catalog tables included). You need to > compare the two numbers on a table-by-table basis, and you'd also have > to ignore any small tables (say smaller than 1000 pages). Also, a page > is 8192 bytes in size (though granted there's a page header that's > something like 16 bytes). > -- > Jim Nasby decibel@decibel.org > EnterpriseDB http://enterprisedb.com 512.569.9461 (cell) > -- Yudhvir Singh Sidhu 408 375 3134 cell