X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AD89ED1B518 for ; Sun, 28 Sep 2003 01:54:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 36741-09 for ; Sat, 27 Sep 2003 22:54:04 -0300 (ADT) Received: from lists.frmug.org (frmug-gw.frmug.org [193.56.58.252]) by svr1.postgresql.org (Postfix) with ESMTP id 585DFD1B511 for ; Sat, 27 Sep 2003 22:54:00 -0300 (ADT) Received: by lists.frmug.org (Postfix/TLS, from userid 66) id B259520F67; Sun, 28 Sep 2003 03:54:00 +0200 (CEST) Received: (from elrond@localhost) by memo.frmug.org (8.11.6/8.11.6) id h8S1rDK77591 for pgsql-sql@postgresql.org; Sun, 28 Sep 2003 03:53:13 +0200 (CEST) (envelope-from pgsql-sql@phoe.frmug.org) X-Authentication-Warning: memo.frmug.org: elrond set sender to pgsql-sql@phoe.frmug.org using -f Date: Sun, 28 Sep 2003 03:53:13 +0200 From: Bertrand Petit To: PostgreSQL-sql Subject: Re: pg_class.relpages Message-ID: <20030928035313.B77510@memo.frmug.org> Mail-Followup-To: PostgreSQL-sql References: <20030928021738.A76959@memo.frmug.org> <200309280026.h8S0QGh27132@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200309280026.h8S0QGh27132@candle.pha.pa.us>; from pgman@candle.pha.pa.us on Sat, Sep 27, 2003 at 08:26:16PM -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/354 X-Sequence-Number: 15332 On Sat, Sep 27, 2003 at 08:26:16PM -0400, Bruce Momjian wrote: > Bertrand Petit wrote: > > > > Does the figures stored in pg_class.relpages include the pages > > consumed by the toast tables linked to a normal table? > > No. See the chapter on monitoring disk space for more information. Okay. I eventually wrote the following query that lists tables and indices sizes. A view similar to this query might my useful for the general public if defined in the information schema. SELECT pg_namespace.nspname AS schema, COALESCE((SELECT class3.relname FROM pg_class AS class3, pg_index WHERE class1.oid=pg_index.indexrelid AND class3.oid=pg_index.indrelid), class1.relname) AS table, CASE WHEN class1.relkind='r' THEN NULL ELSE class1.relname END AS index, (SELECT COALESCE(class1.relpages+SUM(class2.relpages), class1.relpages) * 8 FROM pg_class AS class2 WHERE class2.oid IN (class1.reltoastrelid, class1.reltoastidxid)) AS size FROM pg_class AS class1, pg_namespace WHERE class1.relnamespace = pg_namespace.oid AND pg_namespace.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND class1.relkind IN ('r', 'i') ORDER BY class1.relnamespace ASC, class1.relname ASC, class1.relkind DESC -- %!PS 297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100 180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180 0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont 240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage