Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 27CCF64FD32 for ; Sun, 31 Aug 2008 13:18:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45622-04 for ; Sun, 31 Aug 2008 13:18:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.01.com (lb-2.01.com [38.98.186.147]) by postgresql.org (Postfix) with ESMTP id B704E64FCF9 for ; Sun, 31 Aug 2008 13:18:34 -0300 (ADT) Received: from asav-1.01.com (localhost.localdomain [127.0.0.1]) by asav-1.01.com (8.13.1/8.13.1) with SMTP id m7VGIQcd001421; Sun, 31 Aug 2008 11:18:26 -0500 Received: from smtp-1.01.com (smtp-1.01.com [38.98.186.157]) by asav-1.01.com (asav-1.01.com [10.25.1.11]) id k7UBIQ0518665230s2 ret-id none; Sun, 31 Aug 2008 11:18:26 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-1.01.com (Postfix) with ESMTP id 2443CE3D1D; Sun, 31 Aug 2008 11:18:26 -0500 (CDT) Received: from smtp-1.01.com ([127.0.0.1]) by localhost (smtp-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id koPUHCJgAnga; Sun, 31 Aug 2008 11:18:26 -0500 (CDT) Received: from [10.10.10.18] (8.202-62-69.ftth.swbr.surewest.net [69.62.202.8]) by smtp-1.01.com (Postfix) with ESMTP id D7ECCE33DD; Sun, 31 Aug 2008 11:18:23 -0500 (CDT) Message-ID: <48BAC44F.6090909@frostconsultingllc.com> Date: Sun, 31 Aug 2008 09:18:23 -0700 From: Jeff Frost Organization: Frost Consulting, LLC User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Alvaro Herrera CC: Tom Lane , pgsql-admin@postgresql.org Subject: Re: vacuum verbose relations reporting References: <11312.1219794535@sss.pgh.pa.us> <20080827013612.GT4920@alvh.no-ip.org> <48B4EDF7.9080505@frostconsultingllc.com> In-Reply-To: <48B4EDF7.9080505@frostconsultingllc.com> Content-Type: multipart/alternative; boundary="------------000505040600050601020909" X-FSL-MailScanner-Information: Please contact postmaster@01.com for more information X-FSL-MailScanner: Found to be clean X-FSL-MailScanner-SpamCheck: X-FSL-MailScanner-From: jeff@frostconsultingllc.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200808/246 X-Sequence-Number: 30091 This is a multi-part message in MIME format. --------------000505040600050601020909 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Jeff Frost wrote: > Alvaro Herrera wrote: >> Jeff Frost wrote: >> >> >>> Tom, is there an easy (or hard) way to count relations from all DBs by >>> using the system catalogs? >>> >> >> Just do a count(*) from pg_class where relkind in ('r', 't', 'i'), and >> sum across all databases (you need to connect to each one). >> >> (Actually you only need to count indexes that are btrees, if you need >> such a distinction. Other indexes do not use the FSM as far as I know). >> > Perfect, so here's a little script that does the trick then: > > #!/bin/sh > > PSQL=/usr/bin/psql > DATABASES=$($PSQL -lt | awk {'print $1'} | grep -v template0 ) > RELATIONS=0 > > for DB in $DATABASES; do > RELATIONS=$(($RELATIONS + $($PSQL --tuples-only --command "select > count(*) from pg_class where relkind IN ('r', 't', 'i');" $DB) )) > done > > echo $RELATIONS > I guess this isn't entirely accurate, as the above script returns 35883, but vacuum verbose returns: INFO: free space map contains 111435 pages in 10005 relations If I take out the toast tables and indexes, I get a result much closer to what vacuum verbose returns: 10626 which might just be because the vacuum verbose ran a few hours ago. So, the question is, do the FSM settings take into account toast tables and indexes as Alvaro suggested and vacuum verbose isn't properly reporting on it? -- Jeff Frost, Owner Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 916-647-6411 FAX: 916-405-4032 --------------000505040600050601020909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

Jeff Frost wrote:
Alvaro Herrera wrote:
Jeff Frost wrote:

  
Tom, is there an easy (or hard) way to count relations from all DBs by 
using the system catalogs?
    

Just do a count(*) from pg_class where relkind in ('r', 't', 'i'), and
sum across all databases (you need to connect to each one).

(Actually you only need to count indexes that are btrees, if you need
such a distinction.  Other indexes do not use the FSM as far as I know).
  
Perfect, so here's a little script that does the trick then:

#!/bin/sh

PSQL=/usr/bin/psql
DATABASES=$($PSQL -lt |  awk {'print $1'} | grep -v template0 )
RELATIONS=0

for DB in $DATABASES; do
    RELATIONS=$(($RELATIONS + $($PSQL --tuples-only --command "select count(*) from pg_class where relkind IN ('r', 't', 'i');" $DB) ))
done

echo $RELATIONS

I guess this isn't entirely accurate, as the above script returns 35883, but vacuum verbose returns:

INFO:  free space map contains 111435 pages in 10005 relations

If I take out the toast tables and indexes, I get a result much closer to what vacuum verbose returns: 10626  which might just be because the vacuum verbose ran a few hours ago.

So, the question is, do the FSM settings take into account toast tables and indexes as Alvaro suggested and vacuum verbose isn't properly reporting on it?


-- 
Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 916-647-6411	FAX: 916-405-4032
--------------000505040600050601020909--